MOTION
0.01
Framework for mixed-protocol multi-party computation
|
Go to the documentation of this file.
9 #ifndef POOLED_WORK_STEALING_H
10 #define POOLED_WORK_STEALING_H
14 #include <condition_variable>
20 #include <boost/config.hpp>
21 #include <boost/intrusive_ptr.hpp>
23 #include <boost/fiber/algo/algorithm.hpp>
24 #include <boost/fiber/context.hpp>
25 #include <boost/fiber/detail/config.hpp>
26 #include <boost/fiber/detail/context_spinlock_queue.hpp>
27 #include <boost/fiber/detail/context_spmc_queue.hpp>
28 #include <boost/fiber/scheduler.hpp>
29 #include <boost/thread/barrier.hpp>
36 std::shared_ptr<pool_ctx> pool_ctx_;
39 std::uint32_t thread_count_;
40 #ifdef BOOST_FIBERS_USE_SPMC_QUEUE
41 boost::fibers::detail::context_spmc_queue rqueue_ {};
43 boost::fibers::detail::context_spinlock_queue rqueue_ {};
46 std::condition_variable cnd_{};
50 static void init_(std::uint32_t, std::vector<boost::intrusive_ptr<pooled_work_stealing>>&);
53 static std::shared_ptr<pool_ctx>
create_pool_ctx(std::uint32_t,
bool =
false);
63 virtual void awakened(boost::fibers::context*) noexcept;
65 virtual boost::fibers::context*
pick_next() noexcept;
67 virtual boost::fibers::context*
steal() noexcept {
68 return rqueue_.steal();
72 return !rqueue_.empty();
75 virtual void suspend_until(std::chrono::steady_clock::time_point
const&) noexcept;
77 virtual void notify() noexcept;
82 #endif // POOLED_WORK_STEALING_H
static std::shared_ptr< pool_ctx > create_pool_ctx(std::uint32_t, bool=false)
Definition: pooled_work_stealing.cpp:37
virtual boost::fibers::context * pick_next() noexcept
Definition: pooled_work_stealing.cpp:65
virtual void notify() noexcept
Definition: pooled_work_stealing.cpp:121
~pooled_work_stealing()
Definition: pooled_work_stealing.cpp:52
std::vector< pooled_work_stealing * > schedulers_
Definition: pooled_work_stealing.cpp:33
pooled_work_stealing(std::shared_ptr< pool_ctx >)
Definition: pooled_work_stealing.cpp:43
const std::uint32_t thread_count_
Definition: pooled_work_stealing.cpp:30
Definition: pooled_work_stealing.cpp:21
pool_ctx(std::uint32_t thread_count, bool suspend)
Definition: pooled_work_stealing.cpp:22
virtual void awakened(boost::fibers::context *) noexcept
Definition: pooled_work_stealing.cpp:58
virtual void suspend_until(std::chrono::steady_clock::time_point const &) noexcept
Definition: pooled_work_stealing.cpp:101
Definition: pooled_work_stealing.hpp:35
std::atomic< std::uint32_t > counter_
Definition: pooled_work_stealing.cpp:32
const bool suspend_
Definition: pooled_work_stealing.cpp:31
boost::barrier barrier_
Definition: pooled_work_stealing.cpp:34
virtual bool has_ready_fibers() const noexcept
Definition: pooled_work_stealing.hpp:71
pooled_work_stealing & operator=(pooled_work_stealing const &)=delete
virtual boost::fibers::context * steal() noexcept
Definition: pooled_work_stealing.hpp:67