mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
outcomment lockfree queue tests
This commit is contained in:
parent
e15b53b224
commit
a00d7981e5
15
test.cpp
15
test.cpp
@ -16,7 +16,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include "concurrentqueue.h"
|
// #include "concurrentqueue.h"
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
@ -264,6 +264,7 @@ public:
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
class DispatcherPool
|
class DispatcherPool
|
||||||
{
|
{
|
||||||
enum TerminationMode
|
enum TerminationMode
|
||||||
@ -283,7 +284,7 @@ class DispatcherPool
|
|||||||
|
|
||||||
std::condition_variable _condition;
|
std::condition_variable _condition;
|
||||||
|
|
||||||
moodycamel::ConcurrentQueue<Callable> _queue;
|
// moodycamel::ConcurrentQueue<Callable> _queue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DispatcherPool() : DispatcherPool(std::thread::hardware_concurrency()) { }
|
DispatcherPool() : DispatcherPool(std::thread::hardware_concurrency()) { }
|
||||||
@ -295,7 +296,7 @@ public:
|
|||||||
_pool.emplace_back([&, i]
|
_pool.emplace_back([&, i]
|
||||||
{
|
{
|
||||||
// Reserve the consumer token
|
// Reserve the consumer token
|
||||||
moodycamel::ConsumerToken token(_queue);
|
// moodycamel::ConsumerToken token(_queue);
|
||||||
|
|
||||||
Callable callable;
|
Callable callable;
|
||||||
while (_shutdown != TERMINATE)
|
while (_shutdown != TERMINATE)
|
||||||
@ -363,6 +364,7 @@ public:
|
|||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
int main(int /*argc*/, char** /*argv*/)
|
int main(int /*argc*/, char** /*argv*/)
|
||||||
{
|
{
|
||||||
@ -684,10 +686,11 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DispatcherPool countPool(1);
|
// DispatcherPool countPool(1);
|
||||||
|
|
||||||
DispatcherPool pool;
|
// DispatcherPool pool;
|
||||||
|
|
||||||
|
/*
|
||||||
auto const seed = std::chrono::steady_clock::now().time_since_epoch().count();
|
auto const seed = std::chrono::steady_clock::now().time_since_epoch().count();
|
||||||
|
|
||||||
std::mt19937 rng(static_cast<unsigned int>(seed));
|
std::mt19937 rng(static_cast<unsigned int>(seed));
|
||||||
@ -731,5 +734,7 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
countPool.Await();
|
countPool.Await();
|
||||||
|
|
||||||
std::cout << container.size() << " == " << counter;
|
std::cout << container.size() << " == " << counter;
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user