-
Notifications
You must be signed in to change notification settings - Fork 59
class fiber
windoze edited this page Nov 24, 2014
·
8 revisions
Fibers allow multiple pieces of code to run asynchronously and simultaneously.
-
Types
-
id
: The fiber id type -
attributes
: Fiber attributes
-
-
Methods
fiber()
fiber( fiber&& other )
-
template< class Function, class... Args > explicit fiber( Function&& f, Args&&... args )
Creates new fiber object and associates it with a fiber of execution.-
other
: another fiber object to construct this fiber object with -
f
: function to execute in the new fiber -
args...
: arguments to pass to the new function
-
-
operator=( fiber&& other )
Assigns the state of other to*this
using move semantics. -
bool joinable() const
Checks whether the fiber is joinable, a fiber is joinable only if it is:- The fiber is not the current fiber.
- The fiber has been started.
- The fiber has not been joined.
- The fiber is running in the same scheduler as the current fiber.
-
fiber::id get_id() const
Returns the id of the fiber -
static unsigned hardware_concurrency()
Returns number of concurrent fibers supported by the implementation. The value should be considered only a hint. -
void join(bool propagate_exception=false)
Blocks the current fiber until the fiber identified by*this
finishes its execution.-
propagate_exception
Propagate uncaught exception to the fiber callsjoin()
if set totrue
. If a fiber ends with uncaught exception that not propagated to other fiber,std::terminate()
will be called.
The default value of the parameter isfalse
, this behavior consists withstd::thread
.
-
-
void detach()
Separates the fiber of execution from the fiber object, allowing execution to continue independently.
After calling detach*this
no longer owns any fiber. -
void swap(fiber &other)
Exchanges two fiber objects.-
other
: the fiber to swap with
-
-
Non-member functions
-
void std::swap( fiber &lhs, fiber &rhs )
Overloads thestd::swap
algorithm forfiber
. Exchanges the state of lhs with that of rhs. Effectively callslhs.swap(rhs)
.
-