mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-02 08:52:07 +00:00
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
// Copyright Oliver Kowalke 2013.
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
#ifndef WORKSTEALING_ROUND_ROBIN_H
|
|
#define WORKSTEALING_ROUND_ROBIN_H
|
|
|
|
#include <deque>
|
|
|
|
#include <boost/config.hpp>
|
|
#include <boost/thread/mutex.hpp>
|
|
|
|
#include <boost/fiber/detail/config.hpp>
|
|
#include <boost/fiber/detail/fifo.hpp>
|
|
#include <boost/fiber/detail/worker_fiber.hpp>
|
|
#include <boost/fiber/fiber_manager.hpp>
|
|
|
|
#ifdef BOOST_HAS_ABI_HEADERS
|
|
# include BOOST_ABI_PREFIX
|
|
#endif
|
|
|
|
# if defined(BOOST_MSVC)
|
|
# pragma warning(push)
|
|
# pragma warning(disable:4251 4275)
|
|
# endif
|
|
|
|
class workstealing_round_robin : public boost::fibers::sched_algorithm
|
|
{
|
|
private:
|
|
typedef std::deque< boost::fibers::detail::worker_fiber * > rqueue_t;
|
|
|
|
boost::mutex mtx_;
|
|
rqueue_t rqueue_;
|
|
|
|
public:
|
|
virtual void awakened( boost::fibers::detail::worker_fiber *);
|
|
|
|
virtual boost::fibers::detail::worker_fiber * pick_next();
|
|
|
|
virtual void priority( boost::fibers::detail::worker_fiber *, int) BOOST_NOEXCEPT;
|
|
|
|
boost::fibers::fiber steal();
|
|
};
|
|
|
|
# if defined(BOOST_MSVC)
|
|
# pragma warning(pop)
|
|
# endif
|
|
|
|
#ifdef BOOST_HAS_ABI_HEADERS
|
|
# include BOOST_ABI_SUFFIX
|
|
#endif
|
|
|
|
#endif // WORKSTEALING_ROUND_ROBIN_H
|