mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-11 11:42:23 +00:00
some fixes for asio exmaples - not compiling
This commit is contained in:
@@ -21,8 +21,7 @@
|
||||
#include <boost/asio/handler_type.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fiber/detail/scheduler.hpp>
|
||||
#include <boost/fiber/fiber.hpp>
|
||||
#include <boost/fiber/all.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
@@ -60,7 +59,7 @@ public:
|
||||
}
|
||||
|
||||
//private:
|
||||
boost::fibers::detail::fiber_base * fiber_;
|
||||
boost::fibers::fiber_context * fiber_;
|
||||
Handler & handler_;
|
||||
boost::system::error_code * ec_;
|
||||
T * value_;
|
||||
@@ -90,7 +89,7 @@ public:
|
||||
}
|
||||
|
||||
//private:
|
||||
boost::fibers::detail::fiber_base * fiber_;
|
||||
boost::fibers::fiber_context * fiber_;
|
||||
Handler & handler_;
|
||||
boost::system::error_code * ec_;
|
||||
};
|
||||
@@ -185,7 +184,7 @@ public:
|
||||
{
|
||||
fibers::detail::spinlock splk;
|
||||
std::unique_lock< fibers::detail::spinlock > lk( splk);
|
||||
boost::fibers::fm_wait(lk);
|
||||
boost::fibers::detail::scheduler::instance()->wait(lk);
|
||||
if ( ! out_ec_ && ec_) throw boost::system::system_error( ec_);
|
||||
return value_;
|
||||
}
|
||||
@@ -213,7 +212,7 @@ public:
|
||||
{
|
||||
fibers::detail::spinlock splk;
|
||||
std::unique_lock< fibers::detail::spinlock > lk( splk);
|
||||
boost::fibers::fm_wait(lk);
|
||||
boost::fibers::detail::scheduler::instance()->wait(lk);
|
||||
if ( ! out_ec_ && ec_) throw boost::system::system_error( ec_);
|
||||
}
|
||||
|
||||
@@ -240,7 +239,7 @@ struct spawn_data : private noncopyable
|
||||
{}
|
||||
|
||||
boost::asio::io_service& io_svc_;
|
||||
boost::fibers::detail::fiber_base* fiber_;
|
||||
boost::fibers::fiber_context* fiber_;
|
||||
Handler handler_;
|
||||
bool call_handler_;
|
||||
Function function_;
|
||||
@@ -252,7 +251,7 @@ struct fiber_entry_point
|
||||
void operator()()
|
||||
{
|
||||
shared_ptr< spawn_data< Handler, Function > > data( data_);
|
||||
data->fiber_ = boost::fibers::fm_active();
|
||||
data->fiber_ = boost::fibers::detail::scheduler::instance()->active();
|
||||
const basic_yield_context< Handler > yield(
|
||||
data->fiber_, data->handler_);
|
||||
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/handler_type.hpp>
|
||||
#include <boost/exception/all.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/thread/detail/memory.hpp>
|
||||
|
||||
#include <boost/fiber/future/future.hpp>
|
||||
#include <boost/fiber/future/promise.hpp>
|
||||
#include <boost/fiber/all.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
@@ -38,17 +40,17 @@ public:
|
||||
// Construct from use_future special value.
|
||||
template< typename Allocator >
|
||||
promise_handler( boost::fibers::asio::use_future_t< Allocator > uf) :
|
||||
promise_( std::make_shared< boost::fibers::promise< T > >(
|
||||
uf.get_allocator(), std::allocator_arg, uf.get_allocator() ) )
|
||||
promise_( boost::make_shared< boost::fibers::promise< T > >(
|
||||
uf.get_allocator(), boost::allocator_arg, uf.get_allocator() ) )
|
||||
{}
|
||||
|
||||
void operator()( T t)
|
||||
{
|
||||
promise_->set_value( t);
|
||||
//boost::fibers::fm_run();
|
||||
//boost::fibers::detail::scheduler::instance()->run();
|
||||
}
|
||||
|
||||
void operator()( std::error_code const& ec, T t)
|
||||
void operator()( boost::system::error_code const& ec, T t)
|
||||
{
|
||||
if (ec)
|
||||
promise_->set_exception(
|
||||
@@ -59,7 +61,7 @@ public:
|
||||
|
||||
// scheduler::run() resumes a ready fiber
|
||||
// invoke scheduler::run() until no fiber was resumed
|
||||
//boost::fibers::fm_run();
|
||||
//boost::fibers::detail::scheduler::instance()->run();
|
||||
}
|
||||
|
||||
//private:
|
||||
@@ -81,7 +83,7 @@ public:
|
||||
void operator()()
|
||||
{
|
||||
promise_->set_value();
|
||||
//boost::fibers::fm_run();
|
||||
//boost::fibers::detail::scheduler::instance()->run();
|
||||
}
|
||||
|
||||
void operator()( boost::system::error_code const& ec)
|
||||
@@ -95,7 +97,7 @@ public:
|
||||
|
||||
// scheduler::run() resumes a ready fiber
|
||||
// invoke scheduler::run() until no fiber was resumed
|
||||
//boost::fibers::fm_run();
|
||||
//boost::fibers::detail::scheduler::instance()->run();
|
||||
}
|
||||
|
||||
//private:
|
||||
|
||||
@@ -24,7 +24,7 @@ class yield_handler
|
||||
{
|
||||
public:
|
||||
yield_handler( yield_t const& y) :
|
||||
fiber_( boost::fibers::fm_active() ),
|
||||
fiber_( boost::fibers::detail::scheduler::instance()->active() ),
|
||||
ec_( y.ec_), value_( 0)
|
||||
{}
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
|
||||
//private:
|
||||
boost::fibers::detail::fiber_base * fiber_;
|
||||
boost::fibers::fiber_context * fiber_;
|
||||
boost::system::error_code * ec_;
|
||||
T * value_;
|
||||
};
|
||||
@@ -54,7 +54,7 @@ class yield_handler< void >
|
||||
{
|
||||
public:
|
||||
yield_handler( yield_t const& y) :
|
||||
fiber_( boost::fibers::fm_active() ),
|
||||
fiber_( boost::fibers::detail::scheduler::instance()->active() ),
|
||||
ec_( y.ec_)
|
||||
{}
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
}
|
||||
|
||||
//private:
|
||||
boost::fibers::detail::fiber_base * fiber_;
|
||||
boost::fibers::fiber_context * fiber_;
|
||||
boost::system::error_code * ec_;
|
||||
};
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
{
|
||||
fibers::detail::spinlock splk;
|
||||
std::unique_lock< fibers::detail::spinlock > lk( splk);
|
||||
boost::fibers::fm_wait(lk);
|
||||
boost::fibers::detail::scheduler::instance()->wait(lk);
|
||||
if ( ! out_ec_ && ec_)
|
||||
throw_exception( boost::system::system_error( ec_) );
|
||||
return value_;
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
{
|
||||
fibers::detail::spinlock splk;
|
||||
std::unique_lock< fibers::detail::spinlock > lk( splk);
|
||||
boost::fibers::fm_wait(lk);
|
||||
boost::fibers::detail::scheduler::instance()->wait(lk);
|
||||
if ( ! out_ec_ && ec_)
|
||||
throw_exception( boost::system::system_error( ec_) );
|
||||
}
|
||||
|
||||
@@ -4,14 +4,12 @@
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/high_resolution_timer.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fiber/detail/config.hpp>
|
||||
#include <boost/fiber/detail/scheduler.hpp>
|
||||
#include <boost/fiber/all.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
@@ -22,13 +20,13 @@ namespace fibers {
|
||||
namespace asio {
|
||||
|
||||
inline void timer_handler( boost::asio::high_resolution_timer & timer) {
|
||||
boost::fibers::fm_yield();
|
||||
timer.expires_at( boost::fibers::fm_next_wakeup() );
|
||||
boost::fibers::detail::scheduler::instance()->yield();
|
||||
timer.expires_at( boost::fibers::detail::scheduler::instance()->next_wakeup() );
|
||||
timer.async_wait( std::bind( timer_handler, std::ref( timer) ) );
|
||||
}
|
||||
|
||||
inline void run_service( boost::asio::io_service & io_service) {
|
||||
boost::asio::high_resolution_timer timer( io_service, std::chrono::seconds(0) );
|
||||
boost::asio::high_resolution_timer timer( io_service, boost::chrono::seconds(0) );
|
||||
timer.async_wait( std::bind( timer_handler, std::ref( timer) ) );
|
||||
io_service.run();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fiber/detail/fiber_base.hpp>
|
||||
#include <boost/fiber/all.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
* function.
|
||||
*/
|
||||
basic_yield_context(
|
||||
boost::fibers::detail::fiber_base * fib,
|
||||
boost::fibers::fiber_context * fib,
|
||||
Handler& handler) :
|
||||
fiber_( fib),
|
||||
handler_( handler),
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
private:
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
boost::fibers::detail::fiber_base * fiber_;
|
||||
boost::fibers::fiber_context * fiber_;
|
||||
Handler & handler_;
|
||||
boost::system::error_code * ec_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user