2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-20 14:42:21 +00:00

use C++11

This commit is contained in:
Oliver Kowalke
2014-12-27 19:07:42 +01:00
parent ddbdd91ced
commit 2f19be6d67
126 changed files with 19488 additions and 21505 deletions

View File

@@ -6,11 +6,10 @@
#include "boost/fiber/barrier.hpp"
#include <boost/exception/all.hpp>
#include <boost/thread/locks.hpp>
#include <mutex>
#include <system_error>
#include "boost/fiber/exceptions.hpp"
#include "boost/fiber/operations.hpp"
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
@@ -24,33 +23,26 @@ barrier::barrier( std::size_t initial) :
current_( initial_),
cycle_( true),
mtx_(),
cond_()
{
if ( 0 == initial)
boost::throw_exception(
invalid_argument(
system::errc::invalid_argument,
"boost fiber: zero initial barrier count") );
cond_() {
if ( 0 == initial) {
throw invalid_argument( static_cast< int >( std::errc::invalid_argument),
"boost fiber: zero initial barrier count");
}
}
bool
barrier::wait()
{
boost::unique_lock< mutex > lk( mtx_);
barrier::wait() {
std::unique_lock< mutex > lk( mtx_);
bool cycle( cycle_);
if ( 0 == --current_)
{
if ( 0 == --current_) {
cycle_ = ! cycle_;
current_ = initial_;
cond_.notify_all();
return true;
}
else
{
while ( cycle == cycle_)
//FIXME: what happend if fiber is interrupted?
// ++current_ ?
} else {
while ( cycle == cycle_) {
cond_.wait( lk);
}
}
return false;
}