proxygen
TestExecutorTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (TestExecutor, parallel_run)
 

Function Documentation

TEST ( TestExecutor  ,
parallel_run   
)

Definition at line 24 of file TestExecutorTest.cpp.

References folly::pushmi::executor, EXPECT_EQ, m, and mutex.

24  {
25  mutex m;
26  set<thread::id> ids;
27  auto executor = std::make_unique<TestExecutor>(4);
28  const auto numThreads = executor->numThreads();
29  EXPECT_EQ(4, numThreads);
30  for (auto idx = 0U; idx < numThreads * 10; ++idx) {
31  executor->add([&m, &ids]() mutable {
32  /* sleep override */ this_thread::sleep_for(milliseconds(100));
33  lock_guard<mutex> lg(m);
34  ids.insert(this_thread::get_id());
35  });
36  }
37 
38  executor = nullptr;
39  EXPECT_EQ(ids.size(), numThreads);
40 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
static map< string, int > m
std::mutex mutex