9 #if defined(HAVE_CONFIG_H)
13 #include <boost/thread.hpp>
14 #include <boost/test/unit_test.hpp>
21 boost::unique_lock<boost::mutex> lock(mutex);
25 if (rescheduleTime != noTime) {
26 CScheduler::Function f = std::bind(µTask, std::ref(s), std::ref(mutex), std::ref(counter), -delta + 1, noTime);
45 boost::mutex counterMutex[10];
46 int counter[10] = { 0 };
49 auto randomMsec = [](
FastRandomContext& rc) ->
int {
return -11 + rc.randrange(1012); };
50 auto randomDelta = [](
FastRandomContext& rc) ->
int {
return -1000 + rc.randrange(2001); };
58 for (
int i = 0; i < 100; ++i) {
61 int whichCounter = zeroToNine(rng);
63 std::ref(counterMutex[whichCounter]), std::ref(counter[whichCounter]),
64 randomDelta(rng), tReschedule);
73 boost::thread_group microThreads;
74 for (
int i = 0; i < 5; i++)
78 now = std::chrono::system_clock::now();
81 for (
int i = 0; i < 5; i++)
83 for (
int i = 0; i < 100; i++) {
86 int whichCounter = zeroToNine(rng);
88 std::ref(counterMutex[whichCounter]), std::ref(counter[whichCounter]),
89 randomDelta(rng), tReschedule);
94 microTasks.
stop(
true);
95 microThreads.join_all();
98 for (
int i = 0; i < 10; i++) {
100 counterSum += counter[i];
117 boost::thread_group threads;
118 for (
int i = 0; i < 5; ++i) {
129 for (
int i = 0; i < 100; ++i) {
void stop(bool drain=false)
void schedule(Function f, std::chrono::system_clock::time_point t)
std::function< void(void)> Function
size_t getQueueInfo(std::chrono::system_clock::time_point &first, std::chrono::system_clock::time_point &last) const
Class used by CScheduler clients which may schedule multiple jobs which are required to be run serial...
void AddToProcessQueue(std::function< void(void)> func)
Add a callback to be executed.
BOOST_AUTO_TEST_SUITE(cuckoocache_tests)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
clock::time_point time_point
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
BOOST_AUTO_TEST_CASE(manythreads)
void UninterruptibleSleep(const std::chrono::microseconds &n)