Beispiel #1
0
void runNeverFailThread(int numThreads,
                        int n, /*numOps*/
                        MPMCQueue<int, Atom, Dynamic>& cq,
                        std::atomic<uint64_t>& sum,
                        int t) {
  uint64_t threadSum = 0;
  for (int i = t; i < n; i += numThreads) {
    // enq + deq
    EXPECT_TRUE(cq.writeIfNotFull(i));

    int dest = -1;
    EXPECT_TRUE(cq.readIfNotEmpty(dest));
    EXPECT_TRUE(dest >= 0);
    threadSum += dest;
  }
  sum += threadSum;
}
Beispiel #2
0
void runNeverFailUntilThread(int numThreads,
                             int n, /*numOps*/
                             MPMCQueue<int, Atom, Dynamic>& cq,
                             std::atomic<uint64_t>& sum,
                             int t) {
  uint64_t threadSum = 0;
  for (int i = t; i < n; i += numThreads) {
    // enq + deq
    auto soon = Clock::now() + std::chrono::seconds(1);
    EXPECT_TRUE(cq.tryWriteUntil(soon, i));

    int dest = -1;
    EXPECT_TRUE(cq.readIfNotEmpty(dest));
    EXPECT_TRUE(dest >= 0);
    threadSum += dest;
  }
  sum += threadSum;
}