mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-12 12:02:54 +00:00
inline functions for full-specialized tempaltes
This commit is contained in:
@@ -498,13 +498,13 @@ private:
|
||||
bool ready_;
|
||||
exception_ptr except_;
|
||||
|
||||
void mark_ready_and_notify_()
|
||||
inline void mark_ready_and_notify_()
|
||||
{
|
||||
ready_ = true;
|
||||
waiters_.notify_all();
|
||||
}
|
||||
|
||||
void owner_destroyed_()
|
||||
inline void owner_destroyed_()
|
||||
{
|
||||
//TODO: set broken_exception if future was not already done
|
||||
// notify all waiters
|
||||
@@ -512,7 +512,7 @@ private:
|
||||
set_exception_( boost::copy_exception( broken_promise() ) );
|
||||
}
|
||||
|
||||
void set_value_()
|
||||
inline void set_value_()
|
||||
{
|
||||
//TODO: store the value and make the future ready
|
||||
// notify all waiters
|
||||
@@ -522,7 +522,7 @@ private:
|
||||
mark_ready_and_notify_();
|
||||
}
|
||||
|
||||
void set_exception_( exception_ptr except)
|
||||
inline void set_exception_( exception_ptr except)
|
||||
{
|
||||
//TODO: store the exception pointer p into the shared state and make the state ready
|
||||
// done = true, notify all waiters
|
||||
@@ -533,7 +533,7 @@ private:
|
||||
mark_ready_and_notify_();
|
||||
}
|
||||
|
||||
void get_( unique_lock< mutex > & lk)
|
||||
inline void get_( unique_lock< mutex > & lk)
|
||||
{
|
||||
//TODO: the get method waits until the future has a valid result and
|
||||
// (depending on which template is used) retrieves it
|
||||
@@ -545,13 +545,13 @@ private:
|
||||
rethrow_exception( except_);
|
||||
}
|
||||
|
||||
exception_ptr get_exception_ptr_( unique_lock< mutex > & lk)
|
||||
inline exception_ptr get_exception_ptr_( unique_lock< mutex > & lk)
|
||||
{
|
||||
wait_( lk);
|
||||
return except_;
|
||||
}
|
||||
|
||||
void wait_( unique_lock< mutex > & lk) const
|
||||
inline void wait_( unique_lock< mutex > & lk) const
|
||||
{
|
||||
//TODO: blocks until the result becomes available
|
||||
while ( ! ready_)
|
||||
@@ -572,8 +572,8 @@ private:
|
||||
return future_status::ready;
|
||||
}
|
||||
|
||||
future_status wait_until_( unique_lock< mutex > & lk,
|
||||
chrono::high_resolution_clock::time_point const& timeout_time) const
|
||||
inline future_status wait_until_( unique_lock< mutex > & lk,
|
||||
chrono::high_resolution_clock::time_point const& timeout_time) const
|
||||
{
|
||||
//TODO: blocks until the result becomes available or timeout
|
||||
while ( ! ready_)
|
||||
@@ -597,7 +597,7 @@ public:
|
||||
|
||||
virtual ~shared_state() {}
|
||||
|
||||
void owner_destroyed()
|
||||
inline void owner_destroyed()
|
||||
{
|
||||
//TODO: lock mutex
|
||||
// set broken_exception if future was not already done
|
||||
@@ -606,7 +606,7 @@ public:
|
||||
owner_destroyed_();
|
||||
}
|
||||
|
||||
void set_value()
|
||||
inline void set_value()
|
||||
{
|
||||
//TODO: store the value into the shared state and make the state ready
|
||||
// the operation is atomic, i.e. it behaves as though they acquire a single mutex
|
||||
@@ -617,7 +617,7 @@ public:
|
||||
set_value_();
|
||||
}
|
||||
|
||||
void set_exception( exception_ptr except)
|
||||
inline void set_exception( exception_ptr except)
|
||||
{
|
||||
//TODO: store the exception pointer p into the shared state and make the state ready
|
||||
// the operation is atomic, i.e. it behaves as though they acquire a single mutex
|
||||
@@ -628,7 +628,7 @@ public:
|
||||
set_exception_( except);
|
||||
}
|
||||
|
||||
void get()
|
||||
inline void get()
|
||||
{
|
||||
//TODO: the get method waits until the future has a valid result and
|
||||
// (depending on which template is used) retrieves it
|
||||
@@ -643,13 +643,13 @@ public:
|
||||
get_( lk);
|
||||
}
|
||||
|
||||
exception_ptr get_exception_ptr()
|
||||
inline exception_ptr get_exception_ptr()
|
||||
{
|
||||
unique_lock< mutex > lk( mtx_);
|
||||
return get_exception_ptr_( lk);
|
||||
}
|
||||
|
||||
void wait() const
|
||||
inline void wait() const
|
||||
{
|
||||
//TODO: blocks until the result becomes available
|
||||
// valid() == true after the call
|
||||
@@ -666,7 +666,7 @@ public:
|
||||
return wait_for_( lk, timeout_duration);
|
||||
}
|
||||
|
||||
future_status wait_until( chrono::high_resolution_clock::time_point const& timeout_time) const
|
||||
inline future_status wait_until( chrono::high_resolution_clock::time_point const& timeout_time) const
|
||||
{
|
||||
//TODO: blocks until the result becomes available or timeout
|
||||
// valid() == true after the call
|
||||
@@ -674,7 +674,7 @@ public:
|
||||
return wait_until_( lk, timeout_time);
|
||||
}
|
||||
|
||||
void reset()
|
||||
inline void reset()
|
||||
{ ready_ = false; }
|
||||
|
||||
friend inline void intrusive_ptr_add_ref( shared_state * p) BOOST_NOEXCEPT
|
||||
|
||||
@@ -340,7 +340,7 @@ public:
|
||||
//TODO: abandon ownership if any
|
||||
}
|
||||
|
||||
future( BOOST_RV_REF( future< void >) other) BOOST_NOEXCEPT :
|
||||
inline future( BOOST_RV_REF( future< void >) other) BOOST_NOEXCEPT :
|
||||
state_()
|
||||
{
|
||||
//TODO: constructs a future with the shared state of other using move semantics
|
||||
@@ -348,7 +348,7 @@ public:
|
||||
swap( other);
|
||||
}
|
||||
|
||||
future & operator=( BOOST_RV_REF( future< void >) other) BOOST_NOEXCEPT
|
||||
inline future & operator=( BOOST_RV_REF( future< void >) other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: releases any shared state and move-assigns the contents of other to *this
|
||||
// after the assignment, other.valid() == false and this->valid() will yield
|
||||
@@ -358,7 +358,7 @@ public:
|
||||
return * this;
|
||||
}
|
||||
|
||||
void swap( future & other) BOOST_NOEXCEPT
|
||||
inline void swap( future & other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: exchange the shared states of two futures
|
||||
state_.swap( other.state_);
|
||||
@@ -366,10 +366,10 @@ public:
|
||||
|
||||
BOOST_EXPLICIT_OPERATOR_BOOL();
|
||||
|
||||
bool operator!() const BOOST_NOEXCEPT
|
||||
inline bool operator!() const BOOST_NOEXCEPT
|
||||
{ return ! valid(); }
|
||||
|
||||
bool valid() const BOOST_NOEXCEPT
|
||||
inline bool valid() const BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: checks if the future refers to a shared state
|
||||
// this is the case only for futures returned by
|
||||
@@ -380,7 +380,7 @@ public:
|
||||
|
||||
shared_future< void > share();
|
||||
|
||||
void get()
|
||||
inline void get()
|
||||
{
|
||||
//TODO: the get method waits until the future has a valid result and
|
||||
// (depending on which template is used) retrieves it
|
||||
@@ -399,7 +399,7 @@ public:
|
||||
tmp->get();
|
||||
}
|
||||
|
||||
exception_ptr get_exception_ptr()
|
||||
inline exception_ptr get_exception_ptr()
|
||||
{
|
||||
if ( ! valid() )
|
||||
boost::throw_exception(
|
||||
@@ -407,7 +407,7 @@ public:
|
||||
return state_->get_exception_ptr();
|
||||
}
|
||||
|
||||
void wait() const
|
||||
inline void wait() const
|
||||
{
|
||||
//TODO: blocks until the result becomes available
|
||||
// valid() == true after the call
|
||||
@@ -428,7 +428,7 @@ public:
|
||||
return state_->wait_for( timeout_duration);
|
||||
}
|
||||
|
||||
future_status wait_until( chrono::high_resolution_clock::time_point const& timeout_time) const
|
||||
inline future_status wait_until( chrono::high_resolution_clock::time_point const& timeout_time) const
|
||||
{
|
||||
//TODO: blocks until the result becomes available or timeout
|
||||
// valid() == true after the call
|
||||
@@ -805,14 +805,14 @@ public:
|
||||
// destroys the shared state otherwise does nothing
|
||||
}
|
||||
|
||||
shared_future( shared_future const& other) :
|
||||
inline shared_future( shared_future const& other) :
|
||||
state_( other.state_)
|
||||
{
|
||||
//TODO: constructs a shared future that refers to the same shared state,
|
||||
// as other, if there's any
|
||||
}
|
||||
|
||||
shared_future( BOOST_RV_REF( future< void >) other) BOOST_NOEXCEPT :
|
||||
inline shared_future( BOOST_RV_REF( future< void >) other) BOOST_NOEXCEPT :
|
||||
state_()
|
||||
{
|
||||
//TODO: constructs a shared_future with the shared state of other using move semantics
|
||||
@@ -820,7 +820,7 @@ public:
|
||||
state_.swap( other.state_);
|
||||
}
|
||||
|
||||
shared_future( BOOST_RV_REF( shared_future) other) BOOST_NOEXCEPT :
|
||||
inline shared_future( BOOST_RV_REF( shared_future) other) BOOST_NOEXCEPT :
|
||||
state_()
|
||||
{
|
||||
//TODO: constructs a shared_future with the shared state of other using move semantics
|
||||
@@ -828,7 +828,7 @@ public:
|
||||
swap( other);
|
||||
}
|
||||
|
||||
shared_future & operator=( BOOST_RV_REF( shared_future) other) BOOST_NOEXCEPT
|
||||
inline shared_future & operator=( BOOST_RV_REF( shared_future) other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: releases any shared state and move-assigns the contents of other to *this
|
||||
// after the assignment, other.valid() == false and this->valid() will yield
|
||||
@@ -838,7 +838,7 @@ public:
|
||||
return * this;
|
||||
}
|
||||
|
||||
shared_future & operator=( shared_future const& other) BOOST_NOEXCEPT
|
||||
inline shared_future & operator=( shared_future const& other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO:
|
||||
shared_future tmp( boost::move( other) );
|
||||
@@ -846,7 +846,7 @@ public:
|
||||
return * this;
|
||||
}
|
||||
|
||||
shared_future & operator=( BOOST_RV_REF( future< void >) other) BOOST_NOEXCEPT
|
||||
inline shared_future & operator=( BOOST_RV_REF( future< void >) other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO:
|
||||
shared_future tmp( boost::move( other) );
|
||||
@@ -854,13 +854,13 @@ public:
|
||||
return * this;
|
||||
}
|
||||
|
||||
void swap( future< void > & other) BOOST_NOEXCEPT
|
||||
inline void swap( future< void > & other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: exchange the shared states of two shared_futures
|
||||
state_.swap( other.state_);
|
||||
}
|
||||
|
||||
void swap( shared_future & other) BOOST_NOEXCEPT
|
||||
inline void swap( shared_future & other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: exchange the shared states of two shared_futures
|
||||
state_.swap( other.state_);
|
||||
@@ -868,10 +868,10 @@ public:
|
||||
|
||||
BOOST_EXPLICIT_OPERATOR_BOOL();
|
||||
|
||||
bool operator!() const BOOST_NOEXCEPT
|
||||
inline bool operator!() const BOOST_NOEXCEPT
|
||||
{ return ! valid(); }
|
||||
|
||||
bool valid() const BOOST_NOEXCEPT
|
||||
inline bool valid() const BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: checks if the shared_future refers to a shared state
|
||||
// this is the case only for shared_futures returned by
|
||||
@@ -880,7 +880,7 @@ public:
|
||||
return 0 != state_.get();
|
||||
}
|
||||
|
||||
void get() const
|
||||
inline void get() const
|
||||
{
|
||||
//TODO: the get method waits until the shared_future has a valid result and
|
||||
// (depending on which template is used) retrieves it
|
||||
@@ -897,7 +897,7 @@ public:
|
||||
state_->get();
|
||||
}
|
||||
|
||||
exception_ptr get_exception_ptr()
|
||||
inline exception_ptr get_exception_ptr()
|
||||
{
|
||||
if ( ! valid() )
|
||||
boost::throw_exception(
|
||||
@@ -905,7 +905,7 @@ public:
|
||||
return state_->get_exception_ptr();
|
||||
}
|
||||
|
||||
void wait() const
|
||||
inline void wait() const
|
||||
{
|
||||
//TODO: blocks until the result becomes available
|
||||
// valid() == true after the call
|
||||
@@ -926,7 +926,7 @@ public:
|
||||
return state_->wait_for( timeout_duration);
|
||||
}
|
||||
|
||||
future_status wait_until( chrono::high_resolution_clock::time_point const& timeout_time) const
|
||||
inline future_status wait_until( chrono::high_resolution_clock::time_point const& timeout_time) const
|
||||
{
|
||||
//TODO: blocks until the result becomes available or timeout
|
||||
// valid() == true after the call
|
||||
|
||||
@@ -301,16 +301,6 @@ public:
|
||||
// no task and no shared state
|
||||
}
|
||||
|
||||
~packaged_task()
|
||||
{
|
||||
//TODO: abandons the shared state and destroys the stored task object
|
||||
// a usual, if the shared state is abandoned before it was made
|
||||
// ready, an std::future_error exception is stored with the error
|
||||
// code future_errc::broken_promise
|
||||
if ( task_)
|
||||
task_->owner_destroyed();
|
||||
}
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
typedef void( * task_fn)();
|
||||
|
||||
@@ -447,7 +437,17 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
packaged_task( BOOST_RV_REF( packaged_task) other) BOOST_NOEXCEPT :
|
||||
~packaged_task()
|
||||
{
|
||||
//TODO: abandons the shared state and destroys the stored task object
|
||||
// a usual, if the shared state is abandoned before it was made
|
||||
// ready, an std::future_error exception is stored with the error
|
||||
// code future_errc::broken_promise
|
||||
if ( task_)
|
||||
task_->owner_destroyed();
|
||||
}
|
||||
|
||||
inline packaged_task( BOOST_RV_REF( packaged_task) other) BOOST_NOEXCEPT :
|
||||
obtained_( false),
|
||||
task_()
|
||||
{
|
||||
@@ -457,7 +457,7 @@ public:
|
||||
swap( other);
|
||||
}
|
||||
|
||||
packaged_task & operator=( BOOST_RV_REF( packaged_task) other) BOOST_NOEXCEPT
|
||||
inline packaged_task & operator=( BOOST_RV_REF( packaged_task) other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: releases the shared state, if any, destroys the
|
||||
// previously-held task, and moves the shared state
|
||||
@@ -469,7 +469,7 @@ public:
|
||||
return * this;
|
||||
}
|
||||
|
||||
void swap( packaged_task & other) BOOST_NOEXCEPT
|
||||
inline void swap( packaged_task & other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: exchange the shared states of two packaged_task
|
||||
std::swap( obtained_, other.obtained_);
|
||||
@@ -478,16 +478,16 @@ public:
|
||||
|
||||
BOOST_EXPLICIT_OPERATOR_BOOL();
|
||||
|
||||
bool operator!() const BOOST_NOEXCEPT
|
||||
inline bool operator!() const BOOST_NOEXCEPT
|
||||
{ return ! valid(); }
|
||||
|
||||
bool valid() const BOOST_NOEXCEPT
|
||||
inline bool valid() const BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: checks whether *this has a shared state
|
||||
return 0 != task_.get();
|
||||
}
|
||||
|
||||
future< void > get_future()
|
||||
inline future< void > get_future()
|
||||
{
|
||||
//TODO: returns a future which shares the same shared state as *this
|
||||
// get_future can be called only once for each packaged_task
|
||||
@@ -501,7 +501,7 @@ public:
|
||||
return future< void >( task_);
|
||||
}
|
||||
|
||||
void operator()()
|
||||
inline void operator()()
|
||||
{
|
||||
//TODO: calls the stored task with args as the arguments
|
||||
// the return value of the task or any exceptions thrown are
|
||||
@@ -514,7 +514,7 @@ public:
|
||||
task_->run();
|
||||
}
|
||||
|
||||
void reset()
|
||||
inline void reset()
|
||||
{
|
||||
//TODO: resets the state abandoning the results of previous executions
|
||||
// new shared state is constructed
|
||||
|
||||
@@ -342,7 +342,7 @@ public:
|
||||
future_->owner_destroyed();
|
||||
}
|
||||
|
||||
promise( BOOST_RV_REF( promise) other) BOOST_NOEXCEPT :
|
||||
inline promise( BOOST_RV_REF( promise) other) BOOST_NOEXCEPT :
|
||||
obtained_( false),
|
||||
future_()
|
||||
{
|
||||
@@ -352,7 +352,7 @@ public:
|
||||
swap( other);
|
||||
}
|
||||
|
||||
promise & operator=( BOOST_RV_REF( promise) other) BOOST_NOEXCEPT
|
||||
inline promise & operator=( BOOST_RV_REF( promise) other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: take over ownership
|
||||
// other is valid before but in
|
||||
@@ -362,7 +362,7 @@ public:
|
||||
return * this;
|
||||
}
|
||||
|
||||
void swap( promise & other) BOOST_NOEXCEPT
|
||||
inline void swap( promise & other) BOOST_NOEXCEPT
|
||||
{
|
||||
//TODO: exchange the shared states of two promises
|
||||
std::swap( obtained_, other.obtained_);
|
||||
@@ -371,10 +371,10 @@ public:
|
||||
|
||||
BOOST_EXPLICIT_OPERATOR_BOOL();
|
||||
|
||||
bool operator!() const BOOST_NOEXCEPT
|
||||
inline bool operator!() const BOOST_NOEXCEPT
|
||||
{ return 0 == future_.get(); }
|
||||
|
||||
future< void > get_future()
|
||||
inline future< void > get_future()
|
||||
{
|
||||
//TODO: returns a future object associated with the same shared state
|
||||
// exception is thrown if *this has no shared state or get_future
|
||||
@@ -389,7 +389,7 @@ public:
|
||||
return future< void >( future_);
|
||||
}
|
||||
|
||||
void set_value()
|
||||
inline void set_value()
|
||||
{
|
||||
//TODO: store the value into the shared state and make the state ready
|
||||
// the operation is atomic, i.e. it behaves as though they acquire a single mutex
|
||||
@@ -402,7 +402,7 @@ public:
|
||||
future_->set_value();
|
||||
}
|
||||
|
||||
void set_exception( exception_ptr p)
|
||||
inline void set_exception( exception_ptr p)
|
||||
{
|
||||
//TODO: store the exception pointer p into the shared state and make the state ready
|
||||
// the operation is atomic, i.e. it behaves as though they acquire a single mutex
|
||||
|
||||
Reference in New Issue
Block a user