2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-12 12:02:54 +00:00

changed directory structure as required by modularized-boost

This commit is contained in:
Oliver Kowalke
2012-12-09 15:22:59 +01:00
parent de1188faa2
commit 81e62e8962
77 changed files with 0 additions and 0 deletions

86
src/condition.cpp Normal file
View File

@@ -0,0 +1,86 @@
// Copyright Oliver Kowalke 2009.
// 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)
#define BOOST_FIBERS_SOURCE
#include "boost/fiber/condition.hpp"
#include <boost/foreach.hpp>
#include <boost/fiber/detail/scheduler.hpp>
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
namespace boost {
namespace fibers {
condition::condition() :
cmd_( SLEEPING),
waiters_( 0),
enter_mtx_( false),
check_mtx_(),
waiting_()
{}
condition::~condition()
{ BOOST_ASSERT( 0 == waiters_); }
void
condition::notify_one()
{
enter_mtx_.lock();
if ( 0 == waiters_)
{
enter_mtx_.unlock();
return;
}
if ( ! waiting_.empty() )
{
detail::fiber_base::ptr_t f;
do
{
f.swap( waiting_.front() );
waiting_.pop_front();
} while ( f->is_complete() );
if ( f)
detail::scheduler::instance().notify( f);
}
cmd_ = NOTIFY_ONE;
}
void
condition::notify_all()
{
enter_mtx_.lock();
if ( 0 == waiters_)
{
enter_mtx_.unlock();
return;
}
if ( ! waiting_.empty() )
{
BOOST_FOREACH( detail::fiber_base::ptr_t const& f, waiting_)
{
if ( ! f->is_complete() )
detail::scheduler::instance().notify( f);
}
waiting_.clear();
}
cmd_ = NOTIFY_ALL;
}
}}
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif