mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-18 01:52:24 +00:00
use this in capture-list
This commit is contained in:
@@ -272,7 +272,7 @@ public:
|
||||
ctx_( std::allocator_arg, palloc, salloc,
|
||||
// mutable: generated operator() is not const -> enables std::move( fn)
|
||||
// std::make_tuple: stores decayed copies of its args, implicitly unwraps std::reference_wrapper
|
||||
[=,fn_=std::forward< Fn >( fn),tpl_=std::make_tuple( std::forward< Args >( args) ...),
|
||||
[this,fn_=std::forward< Fn >( fn),tpl_=std::make_tuple( std::forward< Args >( args) ...),
|
||||
ctx=boost::context::execution_context::current()] (void *) mutable -> void {
|
||||
try {
|
||||
auto fn( std::move( fn_) );
|
||||
|
||||
@@ -96,13 +96,13 @@ private:
|
||||
}
|
||||
|
||||
void wait_( std::unique_lock< mutex > & lk) const {
|
||||
waiters_.wait( lk, [=](){ return ready_; });
|
||||
waiters_.wait( lk, [this](){ return ready_; });
|
||||
}
|
||||
|
||||
template< class Rep, class Period >
|
||||
future_status wait_for_( std::unique_lock< mutex > & lk,
|
||||
std::chrono::duration< Rep, Period > const& timeout_duration) const {
|
||||
return waiters_.wait_for( lk, timeout_duration, [=](){ return ready_; })
|
||||
return waiters_.wait_for( lk, timeout_duration, [this](){ return ready_; })
|
||||
? future_status::ready
|
||||
: future_status::timeout;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
template< typename Clock, typename Duration >
|
||||
future_status wait_until_( std::unique_lock< mutex > & lk,
|
||||
std::chrono::time_point< Clock, Duration > const& timeout_time) const {
|
||||
return waiters_.wait_until( lk, timeout_time, [=](){ return ready_; })
|
||||
return waiters_.wait_until( lk, timeout_time, [this](){ return ready_; })
|
||||
? future_status::ready
|
||||
: future_status::timeout;
|
||||
}
|
||||
@@ -253,13 +253,13 @@ private:
|
||||
}
|
||||
|
||||
void wait_( std::unique_lock< mutex > & lk) const {
|
||||
waiters_.wait( lk, [=](){ return ready_; });
|
||||
waiters_.wait( lk, [this](){ return ready_; });
|
||||
}
|
||||
|
||||
template< class Rep, class Period >
|
||||
future_status wait_for_( std::unique_lock< mutex > & lk,
|
||||
std::chrono::duration< Rep, Period > const& timeout_duration) const {
|
||||
return waiters_.wait_for( lk, timeout_duration, [=](){ return ready_; })
|
||||
return waiters_.wait_for( lk, timeout_duration, [this](){ return ready_; })
|
||||
? future_status::ready
|
||||
: future_status::timeout;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ private:
|
||||
template< typename Clock, typename Duration >
|
||||
future_status wait_until_( std::unique_lock< mutex > & lk,
|
||||
std::chrono::time_point< Clock, Duration > const& timeout_time) const {
|
||||
return waiters_.wait_until( lk, timeout_time, [=](){ return ready_; })
|
||||
return waiters_.wait_until( lk, timeout_time, [this](){ return ready_; })
|
||||
? future_status::ready
|
||||
: future_status::timeout;
|
||||
}
|
||||
@@ -406,13 +406,13 @@ private:
|
||||
|
||||
inline
|
||||
void wait_( std::unique_lock< mutex > & lk) const {
|
||||
waiters_.wait( lk, [=](){ return ready_; });
|
||||
waiters_.wait( lk, [this](){ return ready_; });
|
||||
}
|
||||
|
||||
template< class Rep, class Period >
|
||||
future_status wait_for_( std::unique_lock< mutex > & lk,
|
||||
std::chrono::duration< Rep, Period > const& timeout_duration) const {
|
||||
return waiters_.wait_for( lk, timeout_duration, [=](){ return ready_; })
|
||||
return waiters_.wait_for( lk, timeout_duration, [this](){ return ready_; })
|
||||
? future_status::ready
|
||||
: future_status::timeout;
|
||||
}
|
||||
@@ -420,7 +420,7 @@ private:
|
||||
template< typename Clock, typename Duration >
|
||||
future_status wait_until_( std::unique_lock< mutex > & lk,
|
||||
std::chrono::time_point< Clock, Duration > const& timeout_time) const {
|
||||
return waiters_.wait_until( lk, timeout_time, [=](){ return ready_; })
|
||||
return waiters_.wait_until( lk, timeout_time, [this](){ return ready_; })
|
||||
? future_status::ready
|
||||
: future_status::timeout;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ context::context( dispatcher_context_t, boost::context::preallocated const& pall
|
||||
flags_( flag_dispatcher_context),
|
||||
scheduler_( nullptr),
|
||||
ctx_( std::allocator_arg, palloc, salloc,
|
||||
[=] (void * vp) -> void {
|
||||
[this,sched] (void * vp) -> void {
|
||||
if ( nullptr != vp) {
|
||||
std::function< void() > * func( static_cast< std::function< void() > * >( vp) );
|
||||
( * func)();
|
||||
|
||||
@@ -299,7 +299,7 @@ scheduler::yield( context * active_ctx) noexcept {
|
||||
// from one ready-queue) the context must be
|
||||
// already suspended until another thread resumes it
|
||||
// (== maked as ready)
|
||||
std::function< void() > func([=](){
|
||||
std::function< void() > func([this,active_ctx](){
|
||||
set_ready( active_ctx);
|
||||
});
|
||||
// resume another fiber
|
||||
|
||||
Reference in New Issue
Block a user