2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-16 13:22:17 +00:00
Files
fiber/src/round_robin.cpp
Oliver Kowalke 726d4d51b9 ++14 polishing
2015-12-01 21:07:11 +01:00

58 lines
1.2 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)
#include "boost/fiber/round_robin.hpp"
#include <boost/assert.hpp>
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
namespace boost {
namespace fibers {
void
round_robin::awakened( context * ctx) noexcept {
BOOST_ASSERT( nullptr != ctx);
BOOST_ASSERT( ! ctx->ready_is_linked() );
ctx->ready_link( ready_queue_);
}
context *
round_robin::pick_next() noexcept {
context * victim{ nullptr };
if ( ! ready_queue_.empty() ) {
victim = & ready_queue_.front();
ready_queue_.pop_front();
BOOST_ASSERT( nullptr != victim);
BOOST_ASSERT( ! victim->ready_is_linked() );
}
return victim;
}
bool
round_robin::has_ready_fibers() const noexcept {
return ! ready_queue_.empty();
}
void
round_robin::suspend_until( std::chrono::steady_clock::time_point const& suspend_time) noexcept {
ev_.reset( suspend_time);
}
void
round_robin::notify() noexcept {
ev_.set();
}
}}
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif