Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Replace boost/random with STL in testUsdStageThreading #2224

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions pxr/usd/usd/testenv/testUsdStageThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
#include "pxr/base/work/dispatcher.h"
#include "pxr/base/work/withScopedParallelism.h"

#include <boost/random.hpp>

#include <random>
#include <thread>

using std::string;
Expand Down Expand Up @@ -151,14 +150,12 @@ _WorkTask(size_t msecsToRun, bool runForever)
// Use a local random number generator to minimize synchronization
// between threads, as would happen with using libc's random().
const std::thread::id threadId = std::this_thread::get_id();
boost::mt19937 mt(std::hash<std::thread::id>()(threadId));
boost::uniform_int<unsigned int> dist(0, _testCases.size()-1);
boost::variate_generator< boost::mt19937, boost::uniform_int<unsigned int> >
gen(mt, dist);
std::mt19937 mt(std::hash<std::thread::id>()(threadId));
std::uniform_int_distribution<unsigned int> dist(0, _testCases.size()-1);

while (runForever || static_cast<size_t>(sw.GetMilliseconds()) < msecsToRun) {
sw.Start();
const int i = gen();
const int i = dist(mt);

printf(" Thread %s running test case %d\n",
TfStringify(threadId).c_str(), i);
Expand Down