| 664 | } |
| 665 | |
| 666 | void ConcurrentQueueTest::randomCalls() |
| 667 | { |
| 668 | QFETCH(const int, queueThreadCount); |
| 669 | QFETCH(const int, userThreadCount); |
| 670 | QVERIFY(userThreadCount > 0); |
| 671 | QFETCH(const bool, boostEnqueueOperationWeight); |
| 672 | |
| 673 | const auto printer = makeMessagePrinter(queueThreadCount); |
| 674 | |
| 675 | ConcurrentQueue queue(queueThreadCount); |
| 676 | printer.printStartedMessage(); |
| 677 | |
| 678 | randomEngineProvider.resetEngines(userThreadCount); |
| 679 | |
| 680 | std::vector<std::thread> userThreads; |
| 681 | userThreads.reserve(userThreadCount - 1); |
| 682 | for (int id = 1; id < userThreadCount; ++id) { |
| 683 | userThreads.emplace_back(RandomCaller(queue, total, id, queueThreadCount, |
| 684 | randomEngineProvider.engine(id), |
| 685 | boostEnqueueOperationWeight)); |
| 686 | } |
| 687 | RandomCaller(queue, total, primaryThreadId, queueThreadCount, |
| 688 | randomEngineProvider.engine(primaryThreadId), |
| 689 | boostEnqueueOperationWeight)(); |
| 690 | |
| 691 | for (auto &t : userThreads) |
| 692 | t.join(); |
| 693 | |
| 694 | waitAndPrint(queue, printer); |
| 695 | |
| 696 | QCOMPARE(total.load(), 0); |
| 697 | } |
| 698 | |
| 699 | QTEST_APPLESS_MAIN(ConcurrentQueueTest) |
| 700 |
nothing calls this directly
no test coverage detected