Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Namespace this_fiber

In general, this_fiber operations may be called from the main fiber — the fiber on which function main() is entered — as well as from an explicitly-launched thread’s thread-function. That is, in many respects the main fiber on each thread can be treated like an explicitly-launched fiber.

namespace boost {
namespace this_fiber {

fibers::fiber::id get_id() noexcept;
void yield() noexcept;
template< typename Clock, typename Duration >
void sleep_until( std::chrono::time_point< Clock, Duration > const&);
template< typename Rep, typename Period >
void sleep_for( std::chrono::duration< Rep, Period > const&);
template< typename PROPS >
PROPS & properties();

}}

Non-member function this_fiber::get_id()

#include <boost/fiber/operations.hpp>

namespace boost {
namespace fibers {

fiber::id get_id() noexcept;

}}

Returns:

An instance of fiber::id that represents the currently executing fiber.

Throws:

Nothing.

Non-member function this_fiber::sleep_until()

#include <boost/fiber/operations.hpp>

namespace boost {
namespace fibers {

template< typename Clock, typename Duration >
void sleep_until( std::chrono::time_point< Clock, Duration > const& abs_time);

}}

Effects:

Suspends the current fiber until the time point specified by abs_time has been reached.

Throws:

timeout-related exceptions.

Note:

The current fiber will not resume before abs_time, but there are no guarantees about how soon after abs_time it might resume.

Note:

timeout-related exceptions are as defined in the C++ Standard, section 30.2.4 Timing specifications [thread.req.timing]: A function that takes an argument which specifies a timeout will throw if, during its execution, a clock, time point, or time duration throws an exception. Such exceptions are referred to as timeout-related exceptions.

Non-member function this_fiber::sleep_for()

#include <boost/fiber/operations.hpp>

namespace boost {
namespace fibers {

template< class Rep, class Period >
void sleep_for( std::chrono::duration< Rep, Period > const& rel_time);

}}

Effects:

Suspends the current fiber until the time duration specified by rel_time has elapsed.

Throws:

timeout-related exceptions.

Note:

The current fiber will not resume before rel_time has elapsed, but there are no guarantees about how soon after that it might resume.

Non-member function this_fiber::yield()

#include <boost/fiber/operations.hpp>

namespace boost {
namespace fibers {

void yield() noexcept;

}}

Effects:

Relinquishes execution control, allowing other fibers to run.

Throws:

Nothing.

Note:

A fiber that calls yield() is not suspended: it is immediately passed to the scheduler as ready to run.

Non-member function this_fiber::properties()

#include <boost/fiber/operations.hpp>

namespace boost {
namespace fibers {

template< typename PROPS >
PROPS & properties();

}}

Preconditions:

use_scheduling_algorithm() has been called from this thread with a subclass of algorithm_with_properties<> with the same template argument PROPS.

Returns:

a reference to the scheduler properties instance for the currently running fiber.

Throws:

std::bad_cast if use_scheduling_algorithm() was called with an algorithm_with_properties subclass with some other template parameter than PROPS.

Note:

algorithm_with_properties<> provides a way for a user-coded scheduler to associate extended properties, such as priority, with a fiber instance. This function allows access to those user-provided properties.

Note:

The first time this function is called from the main fiber of a thread, it may internally yield, permitting other fibers to run.

See also:

Customization


PrevUpHomeNext