add boost on mac
This commit is contained in:
16
macx64/include/boost/coroutine2/all.hpp
Normal file
16
macx64/include/boost/coroutine2/all.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_ALL_H
|
||||
#define BOOST_COROUTINES2_ALL_H
|
||||
|
||||
#include <boost/coroutine2/coroutine.hpp>
|
||||
#include <boost/coroutine2/fixedsize_stack.hpp>
|
||||
#include <boost/coroutine2/pooled_fixedsize_stack.hpp>
|
||||
#include <boost/coroutine2/protected_fixedsize_stack.hpp>
|
||||
#include <boost/coroutine2/segmented_stack.hpp>
|
||||
|
||||
#endif // BOOST_COROUTINES2_ALL_H
|
||||
39
macx64/include/boost/coroutine2/coroutine.hpp
Normal file
39
macx64/include/boost/coroutine2/coroutine.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_COROUTINE_H
|
||||
#define BOOST_COROUTINES2_COROUTINE_H
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/coroutine.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
|
||||
template< typename T >
|
||||
struct coroutine {
|
||||
using pull_type = detail::pull_coroutine< T >;
|
||||
using push_type = detail::push_coroutine< T >;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
using asymmetric_coroutine = coroutine< T >;
|
||||
|
||||
}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_COROUTINE_H
|
||||
30
macx64/include/boost/coroutine2/detail/config.hpp
Normal file
30
macx64/include/boost/coroutine2/detail/config.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_CONFIG_H
|
||||
#define BOOST_COROUTINES2_DETAIL_CONFIG_H
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/detail/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_COROUTINES2_DECL
|
||||
# undef BOOST_COROUTINES2_DECL
|
||||
#endif
|
||||
|
||||
#if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_COROUTINES2_DYN_LINK) ) && ! defined(BOOST_COROUTINES2_STATIC_LINK)
|
||||
# if defined(BOOST_COROUTINES2_SOURCE)
|
||||
# define BOOST_COROUTINES2_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define BOOST_COROUTINES2_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ! defined(BOOST_COROUTINES2_DECL)
|
||||
# define BOOST_COROUTINES2_DECL
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_CONFIG_H
|
||||
45
macx64/include/boost/coroutine2/detail/coroutine.hpp
Normal file
45
macx64/include/boost/coroutine2/detail/coroutine.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_COROUTINE_HPP
|
||||
#define BOOST_COROUTINES2_DETAIL_COROUTINE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename T >
|
||||
class pull_coroutine;
|
||||
|
||||
template< typename T >
|
||||
class push_coroutine;
|
||||
|
||||
}}}
|
||||
|
||||
#include <boost/coroutine2/detail/pull_coroutine.hpp>
|
||||
#include <boost/coroutine2/detail/push_coroutine.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/pull_control_block_cc.hpp>
|
||||
#include <boost/coroutine2/detail/push_control_block_cc.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/pull_coroutine.ipp>
|
||||
#include <boost/coroutine2/detail/push_coroutine.ipp>
|
||||
|
||||
#include <boost/coroutine2/detail/pull_control_block_cc.ipp>
|
||||
#include <boost/coroutine2/detail/push_control_block_cc.ipp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_COROUTINE_HPP
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_CREATE_CONTROLBLOCK_IPP
|
||||
#define BOOST_COROUTINES2_DETAIL_CREATE_CONTROLBLOCK_IPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/context/preallocated.hpp>
|
||||
#include <boost/context/stack_context.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename ControlBlock, typename StackAllocator, typename Fn >
|
||||
ControlBlock * create_control_block( StackAllocator && salloc, Fn && fn) {
|
||||
auto sctx = salloc.allocate();
|
||||
// reserve space for control structure
|
||||
#if defined(BOOST_NO_CXX11_CONSTEXPR) || defined(BOOST_NO_CXX11_STD_ALIGN)
|
||||
void * sp = static_cast< char * >( sctx.sp) - sizeof( ControlBlock);
|
||||
const std::size_t size = sctx.size - sizeof( ControlBlock);
|
||||
#else
|
||||
constexpr std::size_t func_alignment = 64; // alignof( ControlBlock);
|
||||
constexpr std::size_t func_size = sizeof( ControlBlock);
|
||||
// reserve space on stack
|
||||
void * sp = static_cast< char * >( sctx.sp) - func_size - func_alignment;
|
||||
// align sp pointer
|
||||
std::size_t space = func_size + func_alignment;
|
||||
sp = std::align( func_alignment, func_size, sp, space);
|
||||
BOOST_ASSERT( nullptr != sp);
|
||||
// calculate remaining size
|
||||
const std::size_t size = sctx.size - ( static_cast< char * >( sctx.sp) - static_cast< char * >( sp) );
|
||||
#endif
|
||||
// placment new for control structure on coroutine stack
|
||||
return new ( sp) ControlBlock{ context::preallocated( sp, size, sctx),
|
||||
std::forward< StackAllocator >( salloc), std::forward< Fn >( fn) };
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_CREATE_CONTROLBLOCK_IPP
|
||||
36
macx64/include/boost/coroutine2/detail/decay_copy.hpp
Normal file
36
macx64/include/boost/coroutine2/detail/decay_copy.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_DECAY_COPY_H
|
||||
#define BOOST_COROUTINES2_DETAIL_DECAY_COPY_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/context/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename T >
|
||||
typename std::decay< T >::type
|
||||
decay_copy( T && t) {
|
||||
return std::forward< T >( t);
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_DECAY_COPY_H
|
||||
34
macx64/include/boost/coroutine2/detail/disable_overload.hpp
Normal file
34
macx64/include/boost/coroutine2/detail/disable_overload.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_DISABLE_OVERLOAD_H
|
||||
#define BOOST_COROUTINES2_DETAIL_DISABLE_OVERLOAD_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/detail/disable_overload.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename X, typename Y >
|
||||
using disable_overload = boost::context::detail::disable_overload< X, Y >;
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_DISABLE_OVERLOAD_H
|
||||
37
macx64/include/boost/coroutine2/detail/forced_unwind.hpp
Normal file
37
macx64/include/boost/coroutine2/detail/forced_unwind.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_FORCED_UNWIND_HPP
|
||||
#define BOOST_COROUTINES2_DETAIL_FORCED_UNWIND_HPP
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
struct forced_unwind {};
|
||||
|
||||
inline
|
||||
void * unwind_coroutine( void * data) {
|
||||
throw forced_unwind{};
|
||||
return data;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_FORCED_UNWIND_HPP
|
||||
126
macx64/include/boost/coroutine2/detail/pull_control_block_cc.hpp
Normal file
126
macx64/include/boost/coroutine2/detail/pull_control_block_cc.hpp
Normal file
@@ -0,0 +1,126 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2016.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP
|
||||
#define BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP
|
||||
|
||||
#include <exception>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/fiber.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/state.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename T >
|
||||
struct pull_coroutine< T >::control_block {
|
||||
boost::context::fiber c;
|
||||
typename push_coroutine< T >::control_block * other;
|
||||
state_t state;
|
||||
std::exception_ptr except;
|
||||
bool bvalid;
|
||||
typename std::aligned_storage< sizeof( T), alignof( T) >::type storage;
|
||||
|
||||
static void destroy( control_block * cb) noexcept;
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
control_block( context::preallocated, StackAllocator &&, Fn &&);
|
||||
|
||||
control_block( typename push_coroutine< T >::control_block *, boost::context::fiber &) noexcept;
|
||||
|
||||
~control_block();
|
||||
|
||||
control_block( control_block &) = delete;
|
||||
control_block & operator=( control_block &) = delete;
|
||||
|
||||
void deallocate() noexcept;
|
||||
|
||||
void resume();
|
||||
|
||||
void set( T const&);
|
||||
void set( T &&);
|
||||
|
||||
T & get() noexcept;
|
||||
|
||||
bool valid() const noexcept;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct pull_coroutine< T & >::control_block {
|
||||
struct holder {
|
||||
T & t;
|
||||
|
||||
holder( T & t_) :
|
||||
t{ t_ } {
|
||||
}
|
||||
};
|
||||
|
||||
boost::context::fiber c;
|
||||
typename push_coroutine< T & >::control_block * other;
|
||||
state_t state;
|
||||
std::exception_ptr except;
|
||||
bool bvalid;
|
||||
typename std::aligned_storage< sizeof( holder), alignof( holder) >::type storage;
|
||||
|
||||
static void destroy( control_block * cb) noexcept;
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
control_block( context::preallocated, StackAllocator &&, Fn &&);
|
||||
|
||||
control_block( typename push_coroutine< T & >::control_block *, boost::context::fiber &) noexcept;
|
||||
|
||||
control_block( control_block &) = delete;
|
||||
control_block & operator=( control_block &) = delete;
|
||||
|
||||
void deallocate() noexcept;
|
||||
|
||||
void resume();
|
||||
|
||||
void set( T &);
|
||||
|
||||
T & get() noexcept;
|
||||
|
||||
bool valid() const noexcept;
|
||||
};
|
||||
|
||||
struct pull_coroutine< void >::control_block {
|
||||
boost::context::fiber c;
|
||||
push_coroutine< void >::control_block * other;
|
||||
state_t state;
|
||||
std::exception_ptr except;
|
||||
|
||||
static void destroy( control_block * cb) noexcept;
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
control_block( context::preallocated, StackAllocator &&, Fn &&);
|
||||
|
||||
control_block( push_coroutine< void >::control_block *, boost::context::fiber &) noexcept;
|
||||
|
||||
control_block( control_block &) = delete;
|
||||
control_block & operator=( control_block &) = delete;
|
||||
|
||||
void deallocate() noexcept;
|
||||
|
||||
void resume();
|
||||
|
||||
bool valid() const noexcept;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP
|
||||
442
macx64/include/boost/coroutine2/detail/pull_control_block_cc.ipp
Normal file
442
macx64/include/boost/coroutine2/detail/pull_control_block_cc.ipp
Normal file
@@ -0,0 +1,442 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2016.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_IPP
|
||||
#define BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_IPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/detail/config.hpp>
|
||||
|
||||
#include <boost/context/fiber.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
#include <boost/coroutine2/detail/forced_unwind.hpp>
|
||||
#include <boost/coroutine2/detail/wrap.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
// pull_coroutine< T >
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T >::control_block::destroy( control_block * cb) noexcept {
|
||||
boost::context::fiber c = std::move( cb->c);
|
||||
// destroy control structure
|
||||
cb->~control_block();
|
||||
// destroy coroutine's stack
|
||||
cb->state |= state_t::destroy;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator && salloc,
|
||||
Fn && fn) :
|
||||
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
wrap( [this](typename std::decay< Fn >::type & fn_,boost::context::fiber && c) mutable {
|
||||
// create synthesized push_coroutine< T >
|
||||
typename push_coroutine< T >::control_block synthesized_cb{ this, c };
|
||||
push_coroutine< T > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized push_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
return std::move( other->c).resume();
|
||||
},
|
||||
std::forward< Fn >( fn) ) },
|
||||
#else
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
[this,fn_=std::forward< Fn >( fn)](boost::context::fiber && c) mutable {
|
||||
// create synthesized push_coroutine< T >
|
||||
typename push_coroutine< T >::control_block synthesized_cb{ this, c };
|
||||
push_coroutine< T > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized push_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
return std::move( other->c).resume();
|
||||
} },
|
||||
#endif
|
||||
other{ nullptr },
|
||||
state{ state_t::unwind },
|
||||
except{},
|
||||
bvalid{ false },
|
||||
storage{} {
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T >::control_block::control_block( typename push_coroutine< T >::control_block * cb,
|
||||
boost::context::fiber & c_) noexcept :
|
||||
c{ std::move( c_) },
|
||||
other{ cb },
|
||||
state{ state_t::none },
|
||||
except{},
|
||||
bvalid{ false },
|
||||
storage{} {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T >::control_block::~control_block() {
|
||||
// destroy data if set
|
||||
if ( bvalid) {
|
||||
reinterpret_cast< T * >( std::addressof( storage) )->~T();
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T >::control_block::deallocate() noexcept {
|
||||
if ( state_t::none != ( state & state_t::unwind) ) {
|
||||
destroy( this);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T >::control_block::resume() {
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T >::control_block::set( T const& t) {
|
||||
// destroy data if set
|
||||
if ( bvalid) {
|
||||
reinterpret_cast< T * >( std::addressof( storage) )->~T();
|
||||
}
|
||||
::new ( static_cast< void * >( std::addressof( storage) ) ) T( t);
|
||||
bvalid = true;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T >::control_block::set( T && t) {
|
||||
// destroy data if set
|
||||
if ( bvalid) {
|
||||
reinterpret_cast< T * >( std::addressof( storage) )->~T();
|
||||
}
|
||||
::new ( static_cast< void * >( std::addressof( storage) ) ) T( std::move( t) );
|
||||
bvalid = true;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T &
|
||||
pull_coroutine< T >::control_block::get() noexcept {
|
||||
return * reinterpret_cast< T * >( std::addressof( storage) );
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
pull_coroutine< T >::control_block::valid() const noexcept {
|
||||
return nullptr != other && state_t::none == ( state & state_t::complete) && bvalid;
|
||||
}
|
||||
|
||||
|
||||
// pull_coroutine< T & >
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T & >::control_block::destroy( control_block * cb) noexcept {
|
||||
boost::context::fiber c = std::move( cb->c);
|
||||
// destroy control structure
|
||||
cb->~control_block();
|
||||
// destroy coroutine's stack
|
||||
cb->state |= state_t::destroy;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator && salloc,
|
||||
Fn && fn) :
|
||||
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
wrap( [this](typename std::decay< Fn >::type & fn_,boost::context::fiber && c) mutable {
|
||||
// create synthesized push_coroutine< T & >
|
||||
typename push_coroutine< T & >::control_block synthesized_cb{ this, c };
|
||||
push_coroutine< T & > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized push_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
return std::move( other->c).resume();
|
||||
},
|
||||
std::forward< Fn >( fn) ) },
|
||||
#else
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
[this,fn_=std::forward< Fn >( fn)](boost::context::fiber && c) mutable {
|
||||
// create synthesized push_coroutine< T & >
|
||||
typename push_coroutine< T & >::control_block synthesized_cb{ this, c };
|
||||
push_coroutine< T & > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized push_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
return std::move( other->c).resume();
|
||||
} },
|
||||
#endif
|
||||
other{ nullptr },
|
||||
state{ state_t::unwind },
|
||||
except{},
|
||||
bvalid{ false },
|
||||
storage{} {
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T & >::control_block::control_block( typename push_coroutine< T & >::control_block * cb,
|
||||
boost::context::fiber & c_) noexcept :
|
||||
c{ std::move( c_) },
|
||||
other{ cb },
|
||||
state{ state_t::none },
|
||||
except{},
|
||||
bvalid{ false },
|
||||
storage{} {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T & >::control_block::deallocate() noexcept {
|
||||
if ( state_t::none != ( state & state_t::unwind) ) {
|
||||
destroy( this);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T & >::control_block::resume() {
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
pull_coroutine< T & >::control_block::set( T & t) {
|
||||
::new ( static_cast< void * >( std::addressof( storage) ) ) holder{ t };
|
||||
bvalid = true;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T &
|
||||
pull_coroutine< T & >::control_block::get() noexcept {
|
||||
return reinterpret_cast< holder * >( std::addressof( storage) )->t;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
pull_coroutine< T & >::control_block::valid() const noexcept {
|
||||
return nullptr != other && state_t::none == ( state & state_t::complete) && bvalid;
|
||||
}
|
||||
|
||||
|
||||
// pull_coroutine< void >
|
||||
|
||||
inline
|
||||
void
|
||||
pull_coroutine< void >::control_block::destroy( control_block * cb) noexcept {
|
||||
boost::context::fiber c = std::move( cb->c);
|
||||
// destroy control structure
|
||||
cb->~control_block();
|
||||
// destroy coroutine's stack
|
||||
cb->state |= state_t::destroy;
|
||||
}
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator && salloc,
|
||||
Fn && fn) :
|
||||
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
wrap( [this](typename std::decay< Fn >::type & fn_,boost::context::fiber && c) mutable {
|
||||
// create synthesized push_coroutine< void >
|
||||
typename push_coroutine< void >::control_block synthesized_cb{ this, c };
|
||||
push_coroutine< void > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized push_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
return std::move( other->c).resume();
|
||||
},
|
||||
std::forward< Fn >( fn) ) },
|
||||
#else
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
[this,fn_=std::forward< Fn >( fn)]( boost::context::fiber && c) mutable {
|
||||
// create synthesized push_coroutine< void >
|
||||
typename push_coroutine< void >::control_block synthesized_cb{ this, c };
|
||||
push_coroutine< void > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized push_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back to ctx
|
||||
return std::move( other->c).resume();
|
||||
} },
|
||||
#endif
|
||||
other{ nullptr },
|
||||
state{ state_t::unwind },
|
||||
except{} {
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
pull_coroutine< void >::control_block::control_block( push_coroutine< void >::control_block * cb,
|
||||
boost::context::fiber & c_) noexcept :
|
||||
c{ std::move( c_) },
|
||||
other{ cb },
|
||||
state{ state_t::none },
|
||||
except{} {
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
pull_coroutine< void >::control_block::deallocate() noexcept {
|
||||
if ( state_t::none != ( state & state_t::unwind) ) {
|
||||
destroy( this);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
pull_coroutine< void >::control_block::resume() {
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
pull_coroutine< void >::control_block::valid() const noexcept {
|
||||
return nullptr != other && state_t::none == ( state & state_t::complete);
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_IPP
|
||||
301
macx64/include/boost/coroutine2/detail/pull_coroutine.hpp
Normal file
301
macx64/include/boost/coroutine2/detail/pull_coroutine.hpp
Normal file
@@ -0,0 +1,301 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_PULL_COROUTINE_HPP
|
||||
#define BOOST_COROUTINES2_DETAIL_PULL_COROUTINE_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
#include <boost/coroutine2/detail/disable_overload.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename T >
|
||||
class pull_coroutine {
|
||||
private:
|
||||
template< typename X >
|
||||
friend class push_coroutine;
|
||||
|
||||
struct control_block;
|
||||
|
||||
control_block * cb_;
|
||||
|
||||
explicit pull_coroutine( control_block *) noexcept;
|
||||
|
||||
bool has_result_() const noexcept;
|
||||
|
||||
public:
|
||||
template< typename Fn,
|
||||
typename = detail::disable_overload< pull_coroutine, Fn >
|
||||
>
|
||||
explicit pull_coroutine( Fn &&);
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine( StackAllocator &&, Fn &&);
|
||||
|
||||
~pull_coroutine();
|
||||
|
||||
pull_coroutine( pull_coroutine const&) = delete;
|
||||
pull_coroutine & operator=( pull_coroutine const&) = delete;
|
||||
|
||||
pull_coroutine( pull_coroutine &&) noexcept;
|
||||
|
||||
pull_coroutine & operator=( pull_coroutine && other) noexcept {
|
||||
std::swap( cb_, other.cb_);
|
||||
return * this;
|
||||
}
|
||||
|
||||
pull_coroutine & operator()();
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
|
||||
bool operator!() const noexcept;
|
||||
|
||||
T get() noexcept;
|
||||
|
||||
class iterator {
|
||||
private:
|
||||
pull_coroutine< T > * c_{ nullptr };
|
||||
|
||||
void fetch_() noexcept {
|
||||
BOOST_ASSERT( nullptr != c_);
|
||||
if ( ! ( * c_) ) {
|
||||
c_ = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void increment_() {
|
||||
BOOST_ASSERT( nullptr != c_);
|
||||
BOOST_ASSERT( * c_);
|
||||
( * c_)();
|
||||
fetch_();
|
||||
}
|
||||
|
||||
public:
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef typename std::remove_reference< T >::type value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef value_type * pointer;
|
||||
typedef value_type & reference;
|
||||
|
||||
typedef pointer pointer_t;
|
||||
typedef reference reference_t;
|
||||
|
||||
iterator() noexcept = default;
|
||||
|
||||
explicit iterator( pull_coroutine< T > * c) noexcept :
|
||||
c_{ c } {
|
||||
fetch_();
|
||||
}
|
||||
|
||||
bool operator==( iterator const& other) const noexcept {
|
||||
return other.c_ == c_;
|
||||
}
|
||||
|
||||
bool operator!=( iterator const& other) const noexcept {
|
||||
return other.c_ != c_;
|
||||
}
|
||||
|
||||
iterator & operator++() {
|
||||
increment_();
|
||||
return * this;
|
||||
}
|
||||
|
||||
void operator++( int) {
|
||||
increment_();
|
||||
}
|
||||
|
||||
reference_t operator*() const noexcept {
|
||||
return c_->cb_->get();
|
||||
}
|
||||
|
||||
pointer_t operator->() const noexcept {
|
||||
return std::addressof( c_->cb_->get() );
|
||||
}
|
||||
};
|
||||
|
||||
friend class iterator;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
class pull_coroutine< T & > {
|
||||
private:
|
||||
template< typename X >
|
||||
friend class push_coroutine;
|
||||
|
||||
struct control_block;
|
||||
|
||||
control_block * cb_;
|
||||
|
||||
explicit pull_coroutine( control_block *) noexcept;
|
||||
|
||||
bool has_result_() const noexcept;
|
||||
|
||||
public:
|
||||
template< typename Fn,
|
||||
typename = detail::disable_overload< pull_coroutine, Fn >
|
||||
>
|
||||
explicit pull_coroutine( Fn &&);
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine( StackAllocator &&, Fn &&);
|
||||
|
||||
~pull_coroutine();
|
||||
|
||||
pull_coroutine( pull_coroutine const&) = delete;
|
||||
pull_coroutine & operator=( pull_coroutine const&) = delete;
|
||||
|
||||
pull_coroutine( pull_coroutine &&) noexcept;
|
||||
|
||||
pull_coroutine & operator=( pull_coroutine && other) noexcept {
|
||||
std::swap( cb_, other.cb_);
|
||||
return * this;
|
||||
}
|
||||
|
||||
pull_coroutine & operator()();
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
|
||||
bool operator!() const noexcept;
|
||||
|
||||
T & get() noexcept;
|
||||
|
||||
class iterator {
|
||||
private:
|
||||
pull_coroutine< T & > * c_{ nullptr };
|
||||
|
||||
void fetch_() noexcept {
|
||||
BOOST_ASSERT( nullptr != c_);
|
||||
if ( ! ( * c_) ) {
|
||||
c_ = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void increment_() {
|
||||
BOOST_ASSERT( nullptr != c_);
|
||||
BOOST_ASSERT( * c_);
|
||||
( * c_)();
|
||||
fetch_();
|
||||
}
|
||||
|
||||
public:
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef typename std::remove_reference< T >::type value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef value_type * pointer;
|
||||
typedef value_type & reference;
|
||||
|
||||
typedef pointer pointer_t;
|
||||
typedef reference reference_t;
|
||||
|
||||
iterator() noexcept = default;
|
||||
|
||||
explicit iterator( pull_coroutine< T & > * c) noexcept :
|
||||
c_{ c } {
|
||||
fetch_();
|
||||
}
|
||||
|
||||
bool operator==( iterator const& other) const noexcept {
|
||||
return other.c_ == c_;
|
||||
}
|
||||
|
||||
bool operator!=( iterator const& other) const noexcept {
|
||||
return other.c_ != c_;
|
||||
}
|
||||
|
||||
iterator & operator++() {
|
||||
increment_();
|
||||
return * this;
|
||||
}
|
||||
|
||||
void operator++( int) {
|
||||
increment_();
|
||||
}
|
||||
|
||||
reference_t operator*() const noexcept {
|
||||
return c_->cb_->get();
|
||||
}
|
||||
|
||||
pointer_t operator->() const noexcept {
|
||||
return std::addressof( c_->cb_->get() );
|
||||
}
|
||||
};
|
||||
|
||||
friend class iterator;
|
||||
};
|
||||
|
||||
template<>
|
||||
class pull_coroutine< void > {
|
||||
private:
|
||||
template< typename X >
|
||||
friend class push_coroutine;
|
||||
|
||||
struct control_block;
|
||||
|
||||
control_block * cb_;
|
||||
|
||||
explicit pull_coroutine( control_block *) noexcept;
|
||||
|
||||
public:
|
||||
template< typename Fn,
|
||||
typename = detail::disable_overload< pull_coroutine, Fn >
|
||||
>
|
||||
explicit pull_coroutine( Fn &&);
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine( StackAllocator &&, Fn &&);
|
||||
|
||||
~pull_coroutine();
|
||||
|
||||
pull_coroutine( pull_coroutine const&) = delete;
|
||||
pull_coroutine & operator=( pull_coroutine const&) = delete;
|
||||
|
||||
pull_coroutine( pull_coroutine &&) noexcept;
|
||||
|
||||
pull_coroutine & operator=( pull_coroutine && other) noexcept {
|
||||
std::swap( cb_, other.cb_);
|
||||
return * this;
|
||||
}
|
||||
|
||||
pull_coroutine & operator()();
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
|
||||
bool operator!() const noexcept;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
typename pull_coroutine< T >::iterator
|
||||
begin( pull_coroutine< T > & c) {
|
||||
return typename pull_coroutine< T >::iterator( & c);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
typename pull_coroutine< T >::iterator
|
||||
end( pull_coroutine< T > &) {
|
||||
return typename pull_coroutine< T >::iterator();
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_PULL_COROUTINE_HPP
|
||||
228
macx64/include/boost/coroutine2/detail/pull_coroutine.ipp
Normal file
228
macx64/include/boost/coroutine2/detail/pull_coroutine.ipp
Normal file
@@ -0,0 +1,228 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_PULL_COROUTINE_IPP
|
||||
#define BOOST_COROUTINES2_DETAIL_PULL_COROUTINE_IPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
#include <boost/coroutine2/detail/create_control_block.ipp>
|
||||
#include <boost/coroutine2/detail/disable_overload.hpp>
|
||||
#include <boost/coroutine2/fixedsize_stack.hpp>
|
||||
#include <boost/coroutine2/segmented_stack.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
// pull_coroutine< T >
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T >::pull_coroutine( control_block * cb) noexcept :
|
||||
cb_{ cb } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
pull_coroutine< T >::has_result_() const noexcept {
|
||||
return nullptr != cb_->other->t;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename Fn,
|
||||
typename
|
||||
>
|
||||
pull_coroutine< T >::pull_coroutine( Fn && fn) :
|
||||
pull_coroutine{ default_stack(), std::forward< Fn >( fn) } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine< T >::pull_coroutine( StackAllocator && salloc, Fn && fn) :
|
||||
cb_{ create_control_block< control_block >( std::forward< StackAllocator >( salloc), std::forward< Fn >( fn) ) } {
|
||||
if ( ! cb_->valid() ) {
|
||||
cb_->deallocate();
|
||||
cb_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T >::~pull_coroutine() {
|
||||
if ( nullptr != cb_) {
|
||||
cb_->deallocate();
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T >::pull_coroutine( pull_coroutine && other) noexcept :
|
||||
cb_{ nullptr } {
|
||||
std::swap( cb_, other.cb_);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T > &
|
||||
pull_coroutine< T >::operator()() {
|
||||
cb_->resume();
|
||||
return * this;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T >::operator bool() const noexcept {
|
||||
return nullptr != cb_ && cb_->valid();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
pull_coroutine< T >::operator!() const noexcept {
|
||||
return nullptr == cb_ || ! cb_->valid();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T
|
||||
pull_coroutine< T >::get() noexcept {
|
||||
return std::move( cb_->get() );
|
||||
}
|
||||
|
||||
|
||||
// pull_coroutine< T & >
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T & >::pull_coroutine( control_block * cb) noexcept :
|
||||
cb_{ cb } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
pull_coroutine< T & >::has_result_() const noexcept {
|
||||
return nullptr != cb_->other->t;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename Fn,
|
||||
typename
|
||||
>
|
||||
pull_coroutine< T & >::pull_coroutine( Fn && fn) :
|
||||
pull_coroutine{ default_stack(), std::forward< Fn >( fn) } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine< T & >::pull_coroutine( StackAllocator && salloc, Fn && fn) :
|
||||
cb_{ create_control_block< control_block >( std::forward< StackAllocator >( salloc), std::forward< Fn >( fn) ) } {
|
||||
if ( ! cb_->valid() ) {
|
||||
cb_->deallocate();
|
||||
cb_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T & >::~pull_coroutine() {
|
||||
if ( nullptr != cb_) {
|
||||
cb_->deallocate();
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T & >::pull_coroutine( pull_coroutine && other) noexcept :
|
||||
cb_{ nullptr } {
|
||||
std::swap( cb_, other.cb_);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T & > &
|
||||
pull_coroutine< T & >::operator()() {
|
||||
cb_->resume();
|
||||
return * this;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
pull_coroutine< T & >::operator bool() const noexcept {
|
||||
return nullptr != cb_ && cb_->valid();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
pull_coroutine< T & >::operator!() const noexcept {
|
||||
return nullptr == cb_ || ! cb_->valid();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T &
|
||||
pull_coroutine< T & >::get() noexcept {
|
||||
return cb_->get();
|
||||
}
|
||||
|
||||
|
||||
// pull_coroutine< void >
|
||||
|
||||
inline
|
||||
pull_coroutine< void >::pull_coroutine( control_block * cb) noexcept :
|
||||
cb_{ cb } {
|
||||
}
|
||||
|
||||
template< typename Fn,
|
||||
typename
|
||||
>
|
||||
pull_coroutine< void >::pull_coroutine( Fn && fn) :
|
||||
pull_coroutine{ default_stack(), std::forward< Fn >( fn) } {
|
||||
}
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
pull_coroutine< void >::pull_coroutine( StackAllocator && salloc, Fn && fn) :
|
||||
cb_{ create_control_block< control_block >( std::forward< StackAllocator >( salloc), std::forward< Fn >( fn) ) } {
|
||||
if ( ! cb_->valid() ) {
|
||||
cb_->deallocate();
|
||||
cb_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
pull_coroutine< void >::~pull_coroutine() {
|
||||
if ( nullptr != cb_) {
|
||||
cb_->deallocate();
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
pull_coroutine< void >::pull_coroutine( pull_coroutine && other) noexcept :
|
||||
cb_{ nullptr } {
|
||||
std::swap( cb_, other.cb_);
|
||||
}
|
||||
|
||||
inline
|
||||
pull_coroutine< void > &
|
||||
pull_coroutine< void >::operator()() {
|
||||
cb_->resume();
|
||||
return * this;
|
||||
}
|
||||
|
||||
inline
|
||||
pull_coroutine< void >::operator bool() const noexcept {
|
||||
return nullptr != cb_ && cb_->valid();
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
pull_coroutine< void >::operator!() const noexcept {
|
||||
return nullptr == cb_ || ! cb_->valid();
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_PULL_COROUTINE_IPP
|
||||
104
macx64/include/boost/coroutine2/detail/push_control_block_cc.hpp
Normal file
104
macx64/include/boost/coroutine2/detail/push_control_block_cc.hpp
Normal file
@@ -0,0 +1,104 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP
|
||||
#define BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/fiber.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/state.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename T >
|
||||
struct push_coroutine< T >::control_block {
|
||||
boost::context::fiber c;
|
||||
typename pull_coroutine< T >::control_block * other;
|
||||
state_t state;
|
||||
std::exception_ptr except;
|
||||
|
||||
static void destroy( control_block * cb) noexcept;
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
control_block( context::preallocated, StackAllocator &&, Fn &&);
|
||||
|
||||
control_block( typename pull_coroutine< T >::control_block *, boost::context::fiber &) noexcept;
|
||||
|
||||
control_block( control_block &) = delete;
|
||||
control_block & operator=( control_block &) = delete;
|
||||
|
||||
void deallocate() noexcept;
|
||||
|
||||
void resume( T const&);
|
||||
|
||||
void resume( T &&);
|
||||
|
||||
bool valid() const noexcept;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct push_coroutine< T & >::control_block {
|
||||
boost::context::fiber c;
|
||||
typename pull_coroutine< T & >::control_block * other;
|
||||
state_t state;
|
||||
std::exception_ptr except;
|
||||
|
||||
static void destroy( control_block * cb) noexcept;
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
control_block( context::preallocated, StackAllocator &&, Fn &&);
|
||||
|
||||
control_block( typename pull_coroutine< T & >::control_block *, boost::context::fiber &) noexcept;
|
||||
|
||||
control_block( control_block &) = delete;
|
||||
control_block & operator=( control_block &) = delete;
|
||||
|
||||
void deallocate() noexcept;
|
||||
|
||||
void resume( T &);
|
||||
|
||||
bool valid() const noexcept;
|
||||
};
|
||||
|
||||
struct push_coroutine< void >::control_block {
|
||||
boost::context::fiber c;
|
||||
pull_coroutine< void >::control_block * other;
|
||||
state_t state;
|
||||
std::exception_ptr except;
|
||||
|
||||
static void destroy( control_block * cb) noexcept;
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
control_block( context::preallocated, StackAllocator &&, Fn &&);
|
||||
|
||||
control_block( pull_coroutine< void >::control_block *, boost::context::fiber &) noexcept;
|
||||
|
||||
control_block( control_block &) = delete;
|
||||
control_block & operator=( control_block &) = delete;
|
||||
|
||||
void deallocate() noexcept;
|
||||
|
||||
void resume();
|
||||
|
||||
bool valid() const noexcept;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP
|
||||
403
macx64/include/boost/coroutine2/detail/push_control_block_cc.ipp
Normal file
403
macx64/include/boost/coroutine2/detail/push_control_block_cc.ipp
Normal file
@@ -0,0 +1,403 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_IPP
|
||||
#define BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_IPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/detail/config.hpp>
|
||||
|
||||
#include <boost/context/fiber.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
#include <boost/coroutine2/detail/forced_unwind.hpp>
|
||||
#include <boost/coroutine2/detail/wrap.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
// push_coroutine< T >
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
push_coroutine< T >::control_block::destroy( control_block * cb) noexcept {
|
||||
boost::context::fiber c = std::move( cb->c);
|
||||
// destroy control structure
|
||||
cb->~control_block();
|
||||
// destroy coroutine's stack
|
||||
cb->state |= state_t::destroy;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator && salloc,
|
||||
Fn && fn) :
|
||||
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
wrap( [this](typename std::decay< Fn >::type & fn_,boost::context::fiber && c) mutable {
|
||||
// create synthesized pull_coroutine< T >
|
||||
typename pull_coroutine< T >::control_block synthesized_cb{ this, c };
|
||||
pull_coroutine< T > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
other->c = std::move( other->c).resume();
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized pull_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
other->c = std::move( other->c).resume();
|
||||
return std::move( other->c);
|
||||
},
|
||||
std::forward< Fn >( fn) ) },
|
||||
#else
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
[this,fn_=std::forward< Fn >( fn)](boost::context::fiber && c) mutable {
|
||||
// create synthesized pull_coroutine< T >
|
||||
typename pull_coroutine< T >::control_block synthesized_cb{ this, c };
|
||||
pull_coroutine< T > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
other->c = std::move( other->c).resume();
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized pull_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
return std::move( other->c).resume();
|
||||
} },
|
||||
#endif
|
||||
other{ nullptr },
|
||||
state{ state_t::unwind },
|
||||
except{} {
|
||||
c = std::move( c).resume();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T >::control_block::control_block( typename pull_coroutine< T >::control_block * cb,
|
||||
boost::context::fiber & c_) noexcept :
|
||||
c{ std::move( c_) },
|
||||
other{ cb },
|
||||
state{ state_t::none },
|
||||
except{} {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
push_coroutine< T >::control_block::deallocate() noexcept {
|
||||
if ( state_t::none != ( state & state_t::unwind) ) {
|
||||
destroy( this);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
push_coroutine< T >::control_block::resume( T const& data) {
|
||||
// pass data to other context
|
||||
other->set( data);
|
||||
// resume other context
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
push_coroutine< T >::control_block::resume( T && data) {
|
||||
// pass data to other context
|
||||
other->set( std::move( data) );
|
||||
// resume other context
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
push_coroutine< T >::control_block::valid() const noexcept {
|
||||
return state_t::none == ( state & state_t::complete );
|
||||
}
|
||||
|
||||
|
||||
// push_coroutine< T & >
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
push_coroutine< T & >::control_block::destroy( control_block * cb) noexcept {
|
||||
boost::context::fiber c = std::move( cb->c);
|
||||
// destroy control structure
|
||||
cb->~control_block();
|
||||
// destroy coroutine's stack
|
||||
cb->state |= state_t::destroy;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator && salloc,
|
||||
Fn && fn) :
|
||||
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
wrap( [this](typename std::decay< Fn >::type & fn_,boost::context::fiber && c) mutable {
|
||||
// create synthesized pull_coroutine< T & >
|
||||
typename pull_coroutine< T & >::control_block synthesized_cb{ this, c };
|
||||
pull_coroutine< T & > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
other->c = std::move( other->c).resume();
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized pull_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
other->c = std::move( other->c).resume();
|
||||
return std::move( other->c);
|
||||
},
|
||||
std::forward< Fn >( fn) ) },
|
||||
#else
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
[this,fn_=std::forward< Fn >( fn)](boost::context::fiber && c) mutable {
|
||||
// create synthesized pull_coroutine< T & >
|
||||
typename pull_coroutine< T & >::control_block synthesized_cb{ this, c };
|
||||
pull_coroutine< T & > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
other->c = std::move( other->c).resume();
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized pull_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
other->c = std::move( other->c).resume();
|
||||
return std::move( other->c);
|
||||
} },
|
||||
#endif
|
||||
other{ nullptr },
|
||||
state{ state_t::unwind },
|
||||
except{} {
|
||||
c = std::move( c).resume();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T & >::control_block::control_block( typename pull_coroutine< T & >::control_block * cb,
|
||||
boost::context::fiber & c_) noexcept :
|
||||
c{ std::move( c_) },
|
||||
other{ cb },
|
||||
state{ state_t::none },
|
||||
except{} {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
push_coroutine< T & >::control_block::deallocate() noexcept {
|
||||
if ( state_t::none != ( state & state_t::unwind) ) {
|
||||
destroy( this);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void
|
||||
push_coroutine< T & >::control_block::resume( T & data) {
|
||||
// pass data to other context
|
||||
other->set( data);
|
||||
// resume other context
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
push_coroutine< T & >::control_block::valid() const noexcept {
|
||||
return state_t::none == ( state & state_t::complete );
|
||||
}
|
||||
|
||||
|
||||
// push_coroutine< void >
|
||||
|
||||
inline
|
||||
void
|
||||
push_coroutine< void >::control_block::destroy( control_block * cb) noexcept {
|
||||
boost::context::fiber c = std::move( cb->c);
|
||||
// destroy control structure
|
||||
cb->~control_block();
|
||||
// destroy coroutine's stack
|
||||
cb->state |= state_t::destroy;
|
||||
}
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator && salloc, Fn && fn) :
|
||||
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
wrap( [this](typename std::decay< Fn >::type & fn_,boost::context::fiber && c) mutable {
|
||||
// create synthesized pull_coroutine< void >
|
||||
typename pull_coroutine< void >::control_block synthesized_cb{ this, c };
|
||||
pull_coroutine< void > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
other->c = std::move( other->c).resume();
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized pull_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
other->c = std::move( other->c).resume();
|
||||
return std::move( other->c);
|
||||
},
|
||||
std::forward< Fn >( fn) ) },
|
||||
#else
|
||||
c{ std::allocator_arg, palloc, std::forward< StackAllocator >( salloc),
|
||||
[this,fn_=std::forward< Fn >( fn)](boost::context::fiber && c) mutable {
|
||||
// create synthesized pull_coroutine< void >
|
||||
typename pull_coroutine< void >::control_block synthesized_cb{ this, c};
|
||||
pull_coroutine< void > synthesized{ & synthesized_cb };
|
||||
other = & synthesized_cb;
|
||||
other->c = std::move( other->c).resume();
|
||||
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||
try {
|
||||
auto fn = std::move( fn_);
|
||||
// call coroutine-fn with synthesized pull_coroutine as argument
|
||||
fn( synthesized);
|
||||
} catch ( boost::context::detail::forced_unwind const&) {
|
||||
throw;
|
||||
#if defined( BOOST_CONTEXT_HAS_CXXABI_H )
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
// store other exceptions in exception-pointer
|
||||
except = std::current_exception();
|
||||
}
|
||||
}
|
||||
// set termination flags
|
||||
state |= state_t::complete;
|
||||
// jump back
|
||||
other->c = std::move( other->c).resume();
|
||||
return std::move( other->c);
|
||||
} },
|
||||
#endif
|
||||
other{ nullptr },
|
||||
state{ state_t::unwind },
|
||||
except{} {
|
||||
c = std::move( c).resume();
|
||||
}
|
||||
|
||||
inline
|
||||
push_coroutine< void >::control_block::control_block( pull_coroutine< void >::control_block * cb,
|
||||
boost::context::fiber & c_) noexcept :
|
||||
c{ std::move( c_) },
|
||||
other{ cb },
|
||||
state{ state_t::none },
|
||||
except{} {
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
push_coroutine< void >::control_block::deallocate() noexcept {
|
||||
if ( state_t::none != ( state & state_t::unwind) ) {
|
||||
destroy( this);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
push_coroutine< void >::control_block::resume() {
|
||||
c = std::move( c).resume();
|
||||
if ( except) {
|
||||
std::rethrow_exception( except);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
push_coroutine< void >::control_block::valid() const noexcept {
|
||||
return state_t::none == ( state & state_t::complete );
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_IPP
|
||||
254
macx64/include/boost/coroutine2/detail/push_coroutine.hpp
Normal file
254
macx64/include/boost/coroutine2/detail/push_coroutine.hpp
Normal file
@@ -0,0 +1,254 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_PUSH_COROUTINE_HPP
|
||||
#define BOOST_COROUTINES2_DETAIL_PUSH_COROUTINE_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
#include <boost/coroutine2/detail/disable_overload.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename T >
|
||||
class push_coroutine {
|
||||
private:
|
||||
template< typename X >
|
||||
friend class pull_coroutine;
|
||||
|
||||
struct control_block;
|
||||
|
||||
control_block * cb_;
|
||||
|
||||
explicit push_coroutine( control_block *) noexcept;
|
||||
|
||||
public:
|
||||
template< typename Fn,
|
||||
typename = detail::disable_overload< push_coroutine, Fn >
|
||||
>
|
||||
explicit push_coroutine( Fn &&);
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine( StackAllocator &&, Fn &&);
|
||||
|
||||
~push_coroutine();
|
||||
|
||||
push_coroutine( push_coroutine const&) = delete;
|
||||
push_coroutine & operator=( push_coroutine const&) = delete;
|
||||
|
||||
push_coroutine( push_coroutine &&) noexcept;
|
||||
|
||||
push_coroutine & operator=( push_coroutine && other) noexcept {
|
||||
if ( this == & other) return * this;
|
||||
std::swap( cb_, other.cb_);
|
||||
return * this;
|
||||
}
|
||||
|
||||
push_coroutine & operator()( T const&);
|
||||
|
||||
push_coroutine & operator()( T &&);
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
|
||||
bool operator!() const noexcept;
|
||||
|
||||
class iterator {
|
||||
private:
|
||||
push_coroutine< T > * c_{ nullptr };
|
||||
|
||||
public:
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
iterator() noexcept = default;
|
||||
|
||||
explicit iterator( push_coroutine< T > * c) noexcept :
|
||||
c_{ c } {
|
||||
}
|
||||
|
||||
iterator & operator=( T t) {
|
||||
BOOST_ASSERT( nullptr != c_);
|
||||
if ( ! ( * c_)( t) ) {
|
||||
c_ = nullptr;
|
||||
}
|
||||
return * this;
|
||||
}
|
||||
|
||||
bool operator==( iterator const& other) const noexcept {
|
||||
return other.c_ == c_;
|
||||
}
|
||||
|
||||
bool operator!=( iterator const& other) const noexcept {
|
||||
return other.c_ != c_;
|
||||
}
|
||||
|
||||
iterator & operator*() noexcept {
|
||||
return * this;
|
||||
}
|
||||
|
||||
iterator & operator++() noexcept {
|
||||
return * this;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
class push_coroutine< T & > {
|
||||
private:
|
||||
template< typename X >
|
||||
friend class pull_coroutine;
|
||||
|
||||
struct control_block;
|
||||
|
||||
control_block * cb_;
|
||||
|
||||
explicit push_coroutine( control_block *) noexcept;
|
||||
|
||||
public:
|
||||
template< typename Fn,
|
||||
typename = detail::disable_overload< push_coroutine, Fn >
|
||||
>
|
||||
explicit push_coroutine( Fn &&);
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine( StackAllocator &&, Fn &&);
|
||||
|
||||
~push_coroutine();
|
||||
|
||||
push_coroutine( push_coroutine const&) = delete;
|
||||
push_coroutine & operator=( push_coroutine const&) = delete;
|
||||
|
||||
push_coroutine( push_coroutine &&) noexcept;
|
||||
|
||||
push_coroutine & operator=( push_coroutine && other) noexcept {
|
||||
if ( this == & other) return * this;
|
||||
std::swap( cb_, other.cb_);
|
||||
return * this;
|
||||
}
|
||||
|
||||
push_coroutine & operator()( T &);
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
|
||||
bool operator!() const noexcept;
|
||||
|
||||
class iterator {
|
||||
private:
|
||||
push_coroutine< T & > * c_{ nullptr };
|
||||
|
||||
public:
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
iterator() noexcept = default;
|
||||
|
||||
explicit iterator( push_coroutine< T & > * c) noexcept :
|
||||
c_{ c } {
|
||||
}
|
||||
|
||||
iterator & operator=( T & t) {
|
||||
BOOST_ASSERT( nullptr != c_);
|
||||
if ( ! ( * c_)( t) ) {
|
||||
c_ = nullptr;
|
||||
}
|
||||
return * this;
|
||||
}
|
||||
|
||||
bool operator==( iterator const& other) const noexcept {
|
||||
return other.c_ == c_;
|
||||
}
|
||||
|
||||
bool operator!=( iterator const& other) const noexcept {
|
||||
return other.c_ != c_;
|
||||
}
|
||||
|
||||
iterator & operator*() noexcept {
|
||||
return * this;
|
||||
}
|
||||
|
||||
iterator & operator++() noexcept {
|
||||
return * this;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
class push_coroutine< void > {
|
||||
private:
|
||||
template< typename X >
|
||||
friend class pull_coroutine;
|
||||
|
||||
struct control_block;
|
||||
|
||||
control_block * cb_;
|
||||
|
||||
explicit push_coroutine( control_block *) noexcept;
|
||||
|
||||
public:
|
||||
template< typename Fn,
|
||||
typename = detail::disable_overload< push_coroutine, Fn >
|
||||
>
|
||||
explicit push_coroutine( Fn &&);
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine( StackAllocator &&, Fn &&);
|
||||
|
||||
~push_coroutine();
|
||||
|
||||
push_coroutine( push_coroutine const&) = delete;
|
||||
push_coroutine & operator=( push_coroutine const&) = delete;
|
||||
|
||||
push_coroutine( push_coroutine &&) noexcept;
|
||||
|
||||
push_coroutine & operator=( push_coroutine && other) noexcept {
|
||||
if ( this == & other) return * this;
|
||||
std::swap( cb_, other.cb_);
|
||||
return * this;
|
||||
}
|
||||
|
||||
push_coroutine & operator()();
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
|
||||
bool operator!() const noexcept;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
typename push_coroutine< T >::iterator
|
||||
begin( push_coroutine< T > & c) {
|
||||
return typename push_coroutine< T >::iterator( & c);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
typename push_coroutine< T >::iterator
|
||||
end( push_coroutine< T > &) {
|
||||
return typename push_coroutine< T >::iterator();
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_PUSH_COROUTINE_HPP
|
||||
198
macx64/include/boost/coroutine2/detail/push_coroutine.ipp
Normal file
198
macx64/include/boost/coroutine2/detail/push_coroutine.ipp
Normal file
@@ -0,0 +1,198 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_PUSH_COROUTINE_IPP
|
||||
#define BOOST_COROUTINES2_DETAIL_PUSH_COROUTINE_IPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
#include <boost/coroutine2/detail/create_control_block.ipp>
|
||||
#include <boost/coroutine2/detail/disable_overload.hpp>
|
||||
#include <boost/coroutine2/fixedsize_stack.hpp>
|
||||
#include <boost/coroutine2/segmented_stack.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
// push_coroutine< T >
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T >::push_coroutine( control_block * cb) noexcept :
|
||||
cb_{ cb } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename Fn,
|
||||
typename
|
||||
>
|
||||
push_coroutine< T >::push_coroutine( Fn && fn) :
|
||||
push_coroutine{ default_stack(), std::forward< Fn >( fn) } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine< T >::push_coroutine( StackAllocator && salloc, Fn && fn) :
|
||||
cb_{ create_control_block< control_block >( std::forward< StackAllocator >( salloc), std::forward< Fn >( fn) ) } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T >::~push_coroutine() {
|
||||
if ( nullptr != cb_) {
|
||||
cb_->deallocate();
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T >::push_coroutine( push_coroutine && other) noexcept :
|
||||
cb_{ nullptr } {
|
||||
std::swap( cb_, other.cb_);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T > &
|
||||
push_coroutine< T >::operator()( T const& t) {
|
||||
cb_->resume( t);
|
||||
return * this;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T > &
|
||||
push_coroutine< T >::operator()( T && t) {
|
||||
cb_->resume( std::forward< T >( t) );
|
||||
return * this;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T >::operator bool() const noexcept {
|
||||
return nullptr != cb_ && cb_->valid();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
push_coroutine< T >::operator!() const noexcept {
|
||||
return nullptr == cb_ || ! cb_->valid();
|
||||
}
|
||||
|
||||
|
||||
// push_coroutine< T & >
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T & >::push_coroutine( control_block * cb) noexcept :
|
||||
cb_{ cb } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename Fn,
|
||||
typename
|
||||
>
|
||||
push_coroutine< T & >::push_coroutine( Fn && fn) :
|
||||
push_coroutine{ default_stack(), std::forward< Fn >( fn) } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine< T & >::push_coroutine( StackAllocator && salloc, Fn && fn) :
|
||||
cb_{ create_control_block< control_block >( std::forward< StackAllocator >( salloc), std::forward< Fn >( fn) ) } {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T & >::~push_coroutine() {
|
||||
if ( nullptr != cb_) {
|
||||
cb_->deallocate();
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T & >::push_coroutine( push_coroutine && other) noexcept :
|
||||
cb_{ nullptr } {
|
||||
std::swap( cb_, other.cb_);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T & > &
|
||||
push_coroutine< T & >::operator()( T & t) {
|
||||
cb_->resume( t);
|
||||
return * this;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
push_coroutine< T & >::operator bool() const noexcept {
|
||||
return nullptr != cb_ && cb_->valid();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool
|
||||
push_coroutine< T & >::operator!() const noexcept {
|
||||
return nullptr == cb_ || ! cb_->valid();
|
||||
}
|
||||
|
||||
|
||||
// push_coroutine< void >
|
||||
|
||||
inline
|
||||
push_coroutine< void >::push_coroutine( control_block * cb) noexcept :
|
||||
cb_{ cb } {
|
||||
}
|
||||
|
||||
template< typename Fn,
|
||||
typename
|
||||
>
|
||||
push_coroutine< void >::push_coroutine( Fn && fn) :
|
||||
push_coroutine{ default_stack(), std::forward< Fn >( fn) } {
|
||||
}
|
||||
|
||||
template< typename StackAllocator, typename Fn >
|
||||
push_coroutine< void >::push_coroutine( StackAllocator && salloc, Fn && fn) :
|
||||
cb_{ create_control_block< control_block >( std::forward< StackAllocator >( salloc), std::forward< Fn >( fn) ) } {
|
||||
}
|
||||
|
||||
inline
|
||||
push_coroutine< void >::~push_coroutine() {
|
||||
if ( nullptr != cb_) {
|
||||
cb_->deallocate();
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
push_coroutine< void >::push_coroutine( push_coroutine && other) noexcept :
|
||||
cb_{ nullptr } {
|
||||
std::swap( cb_, other.cb_);
|
||||
}
|
||||
|
||||
inline
|
||||
push_coroutine< void > &
|
||||
push_coroutine< void >::operator()() {
|
||||
cb_->resume();
|
||||
return * this;
|
||||
}
|
||||
|
||||
inline
|
||||
push_coroutine< void >::operator bool() const noexcept {
|
||||
return nullptr != cb_ && cb_->valid();
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
push_coroutine< void >::operator!() const noexcept {
|
||||
return nullptr == cb_ || ! cb_->valid();
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_PUSH_COROUTINE_IPP
|
||||
87
macx64/include/boost/coroutine2/detail/state.hpp
Normal file
87
macx64/include/boost/coroutine2/detail/state.hpp
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_DETAIL_ASYMMETRIC_COROUTINE_HPP
|
||||
#define BOOST_COROUTINES2_DETAIL_ASYMMETRIC_COROUTINE_HPP
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
enum class state_t : unsigned int {
|
||||
none = 0,
|
||||
complete = 1 << 1,
|
||||
unwind = 1 << 2,
|
||||
destroy = 1 << 3
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
constexpr state_t
|
||||
operator&( state_t l, state_t r) {
|
||||
return static_cast< state_t >(
|
||||
static_cast< unsigned int >( l) & static_cast< unsigned int >( r) );
|
||||
}
|
||||
|
||||
inline
|
||||
constexpr state_t
|
||||
operator|( state_t l, state_t r) {
|
||||
return static_cast< state_t >(
|
||||
static_cast< unsigned int >( l) | static_cast< unsigned int >( r) );
|
||||
}
|
||||
|
||||
inline
|
||||
constexpr state_t
|
||||
operator^( state_t l, state_t r) {
|
||||
return static_cast< state_t >(
|
||||
static_cast< unsigned int >( l) ^ static_cast< unsigned int >( r) );
|
||||
}
|
||||
|
||||
inline
|
||||
constexpr state_t
|
||||
operator~( state_t l) {
|
||||
return static_cast< state_t >( ~static_cast< unsigned int >( l) );
|
||||
}
|
||||
|
||||
inline
|
||||
state_t &
|
||||
operator&=( state_t & l, state_t r) {
|
||||
l = l & r;
|
||||
return l;
|
||||
}
|
||||
|
||||
inline
|
||||
state_t &
|
||||
operator|=( state_t & l, state_t r) {
|
||||
l = l | r;
|
||||
return l;
|
||||
}
|
||||
|
||||
inline
|
||||
state_t &
|
||||
operator^=( state_t & l, state_t r) {
|
||||
l = l ^ r;
|
||||
return l;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_DETAIL_ASYMMETRIC_COROUTINE_HPP
|
||||
67
macx64/include/boost/coroutine2/detail/wrap.hpp
Normal file
67
macx64/include/boost/coroutine2/detail/wrap.hpp
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINE2_DETAIL_WRAP_H
|
||||
#define BOOST_COROUTINE2_DETAIL_WRAP_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/detail/invoke.hpp>
|
||||
#include <boost/context/fiber.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
namespace detail {
|
||||
|
||||
template< typename Fn1, typename Fn2 >
|
||||
class wrapper {
|
||||
private:
|
||||
typename std::decay< Fn1 >::type fn1_;
|
||||
typename std::decay< Fn2 >::type fn2_;
|
||||
|
||||
public:
|
||||
wrapper( Fn1 && fn1, Fn2 && fn2) :
|
||||
fn1_( std::move( fn1) ),
|
||||
fn2_( std::move( fn2) ) {
|
||||
}
|
||||
|
||||
wrapper( wrapper const&) = delete;
|
||||
wrapper & operator=( wrapper const&) = delete;
|
||||
|
||||
wrapper( wrapper && other) = default;
|
||||
wrapper & operator=( wrapper && other) = default;
|
||||
|
||||
boost::context::fiber
|
||||
operator()( boost::context::fiber && c) {
|
||||
return boost::context::detail::invoke(
|
||||
std::move( fn1_),
|
||||
fn2_,
|
||||
std::forward< boost::context::fiber >( c) );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Fn1, typename Fn2 >
|
||||
wrapper< Fn1, Fn2 >
|
||||
wrap( Fn1 && fn1, Fn2 && fn2) {
|
||||
return wrapper< Fn1, Fn2 >(
|
||||
std::forward< Fn1 >( fn1),
|
||||
std::forward< Fn2 >( fn2) );
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINE2_DETAIL_WRAP_H
|
||||
36
macx64/include/boost/coroutine2/fixedsize_stack.hpp
Normal file
36
macx64/include/boost/coroutine2/fixedsize_stack.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_FIXEDSIZE_H
|
||||
#define BOOST_COROUTINES2_FIXEDSIZE_H
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/fixedsize_stack.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/coroutine.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
|
||||
using fixedsize_stack = boost::context::fixedsize_stack;
|
||||
#if !defined(BOOST_USE_SEGMENTED_STACKS)
|
||||
using default_stack = boost::context::default_stack;
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_FIXEDSIZE_H
|
||||
33
macx64/include/boost/coroutine2/pooled_fixedsize_stack.hpp
Normal file
33
macx64/include/boost/coroutine2/pooled_fixedsize_stack.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_POOLED_FIXEDSIZE_H
|
||||
#define BOOST_COROUTINES2_POOLED_FIXEDSIZE_H
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/pooled_fixedsize_stack.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/coroutine.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
|
||||
using pooled_fixedsize_stack = boost::context::pooled_fixedsize_stack;
|
||||
|
||||
}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_POOLED_FIXEDSIZE_H
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_PROTECTED_FIXEDSIZE_H
|
||||
#define BOOST_COROUTINES2_PROTECTED_FIXEDSIZE_H
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/protected_fixedsize_stack.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/coroutine.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
|
||||
using protected_fixedsize_stack = boost::context::protected_fixedsize_stack;
|
||||
|
||||
}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_PROTECTED_FIXEDSIZE_H
|
||||
38
macx64/include/boost/coroutine2/segmented_stack.hpp
Normal file
38
macx64/include/boost/coroutine2/segmented_stack.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2014.
|
||||
// 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 BOOST_COROUTINES2_SEGMENTED_H
|
||||
#define BOOST_COROUTINES2_SEGMENTED_H
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/segmented_stack.hpp>
|
||||
|
||||
#include <boost/coroutine2/detail/coroutine.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace coroutines2 {
|
||||
|
||||
#if defined(BOOST_USE_SEGMENTED_STACKS)
|
||||
# if ! defined(BOOST_WINDOWS)
|
||||
using segmented_stack = boost::context::segmented_stack;
|
||||
using default_stack = boost::context::default_stack;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_COROUTINES2_SEGMENTED_H
|
||||
Reference in New Issue
Block a user