2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-14 12:42:28 +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,12 @@
#include "boost/fiber/fiber.hpp"
#include <system_error>
#include <boost/assert.hpp>
#include <boost/exception/all.hpp>
#include <boost/scope_exit.hpp>
#include <boost/system/error_code.hpp>
#include "boost/fiber/detail/fiber_base.hpp"
#include "boost/fiber/exceptions.hpp"
#include "boost/fiber/operations.hpp"
@@ -22,92 +23,82 @@ namespace boost {
namespace fibers {
void
fiber::start_()
{
fiber::start_() {
impl_->set_ready();
fm_spawn( impl_.get() );
fm_spawn( impl_);
}
int
fiber::priority() const BOOST_NOEXCEPT
{
fiber::priority() const noexcept {
BOOST_ASSERT( impl_);
return impl_->priority();
}
void
fiber::priority( int prio) BOOST_NOEXCEPT
{
fiber::priority( int prio) noexcept {
BOOST_ASSERT( impl_);
fm_priority( impl_.get(), prio);
fm_priority( impl_, prio);
}
bool
fiber::thread_affinity() const BOOST_NOEXCEPT
{
fiber::thread_affinity() const noexcept {
BOOST_ASSERT( impl_);
return impl_->thread_affinity();
}
void
fiber::thread_affinity( bool req) BOOST_NOEXCEPT
{
fiber::thread_affinity( bool req) noexcept {
BOOST_ASSERT( impl_);
impl_->thread_affinity( req);
}
void
fiber::join()
{
fiber::join() {
BOOST_ASSERT( impl_);
if ( boost::this_fiber::get_id() == get_id() )
boost::throw_exception(
fiber_resource_error(
system::errc::resource_deadlock_would_occur, "boost fiber: trying joining itself") );
if ( ! joinable() )
{
boost::throw_exception(
fiber_resource_error(
system::errc::invalid_argument, "boost fiber: fiber not joinable") );
if ( boost::this_fiber::get_id() == get_id() ) {
throw fiber_resource_error( static_cast< int >( std::errc::resource_deadlock_would_occur),
"boost fiber: trying joining itself");
}
fm_join( impl_.get() );
if ( ! joinable() ) {
throw fiber_resource_error( static_cast< int >( std::errc::invalid_argument),
"boost fiber: fiber not joinable");
}
fm_join( impl_);
// check if joined fiber was interrupted
exception_ptr except( impl_->get_exception() );
std::exception_ptr except( impl_->get_exception() );
ptr_t tmp;
std::swap( tmp, impl_);
tmp.swap( impl_);
// re-throw excpetion
if ( except) rethrow_exception( except);
if ( except) {
std::rethrow_exception( except);
}
}
void
fiber::detach() BOOST_NOEXCEPT
{
fiber::detach() noexcept {
BOOST_ASSERT( impl_);
if ( ! joinable() )
{
boost::throw_exception(
fiber_resource_error(
system::errc::invalid_argument, "boost fiber: fiber not joinable") );
if ( ! joinable() ) {
throw fiber_resource_error( static_cast< int >( std::errc::invalid_argument),
"boost fiber: fiber not joinable");
}
ptr_t tmp;
std::swap( tmp, impl_);
tmp.swap( impl_);
}
void
fiber::interrupt() BOOST_NOEXCEPT
{
fiber::interrupt() noexcept {
BOOST_ASSERT( impl_);
impl_->request_interruption( true);