Lines Matching refs:fiber
14 #include <boost/fiber/all.hpp>
19 class fiber;
20 bool operator<( fiber const& l, fiber const& r) noexcept;
21 void swap( fiber & l, fiber & r) noexcept;
56 boost::fibers::fiber f1; // not-a-fiber
59 boost::fibers::fiber f2( some_fn);
67 A new fiber is launched by passing an object of a callable type that can be
71 that the referenced object outlives the newly-created fiber.
77 boost::fibers::fiber copies_are_safe() {
79 return boost::fibers::fiber( x);
80 } // x is destroyed, but the newly-created fiber has a copy, so this is OK
82 boost::fibers::fiber oops() {
84 return boost::fibers::fiber( std::ref( x) );
85 } // x is destroyed, but the newly-created fiber still has a reference
105 function. After __detach__ is called on a fiber object, that object represents
106 __not_a_fiber__. The fiber object may then safely be destroyed.
108 boost::fibers::fiber( some_fn).detach();
110 __boost_fiber__ provides a number of ways to wait for a running fiber to
111 complete. You can coordinate even with a detached fiber using a [class_link
115 If a detached fiber is still running when the thread[s] main fiber terminates,
120 In order to wait for a fiber to finish, the __join__ member function of the
128 boost::fibers::fiber f( some_fn);
132 If the fiber has already completed, then __join__ returns immediately and
138 When a __fiber__ object representing a valid execution context (the fiber is
139 __joinable__) is destroyed, the program terminates. If you intend the fiber to
143 boost::fibers::fiber f( some_fn);
147 boost::fibers::fiber f(some_fn);
163 Each instance of __fiber_id__ either refers to some fiber, or __not_a_fiber__.
165 not equal to any instances that refer to an actual fiber. The comparison
172 newly-launched fiber.
181 [[Effects:] [A fiber launched with `launch == dispatch` is entered
182 immediately. In other words, launching a fiber with `dispatch` suspends the
183 caller (the previously-running fiber) until the fiber scheduler has a chance
189 [[Effects:] [A fiber launched with `launch == post` is passed to the
190 fiber scheduler as ready, but it is not yet entered. The caller (the
191 previously-running fiber) continues executing. The newly-launched fiber will
192 be entered when the fiber scheduler has a chance to resume it later.]]
198 [section:fiber Class `fiber`]
200 #include <boost/fiber/fiber.hpp>
205 class fiber {
209 constexpr fiber() noexcept;
212 fiber( Fn &&, Args && ...);
215 fiber( ``[link class_launch `launch`]``, Fn &&, Args && ...);
218 fiber( __allocator_arg_t__, StackAllocator &&, Fn &&, Args && ...);
221 …fiber( ``[link class_launch `launch`]``, __allocator_arg_t__, StackAllocator &&, Fn &&, Args && ..…
223 ~fiber();
225 fiber( fiber const&) = delete;
227 fiber & operator=( fiber const&) = delete;
229 fiber( fiber &&) noexcept;
231 fiber & operator=( fiber &&) noexcept;
233 void swap( fiber &) noexcept;
247 bool operator<( fiber const&, fiber const&) noexcept;
249 void swap( fiber &, fiber &) noexcept;
261 constexpr fiber() noexcept;
265 [[Postconditions:] [`this->get_id() == fiber::id()`]]
273 fiber( Fn && fn, Args && ... args);
276 fiber( ``[link class_launch `launch`]`` policy, Fn && fn, Args && ... args);
279 fiber( __allocator_arg_t__, StackAllocator && salloc, Fn && fn, Args && ... args);
282 … fiber( ``[link class_launch `launch`]`` policy, __allocator_arg_t__, StackAllocator && salloc,
288 new fiber. If [class_link launch] is specified (or defaulted) to
289 `post`, the new fiber is marked ["ready] and will be entered at the next
290 opportunity. If `launch` is specified as `dispatch`, the calling fiber
291 is suspended and the new fiber is entered immediately.]]
292 [[Postconditions:] [`*this` refers to the newly created fiber of execution.]]
303 fiber( fiber && other) noexcept;
306 [[Effects:] [Transfers ownership of the fiber managed by `other` to the newly
308 [[Postconditions:] [`other.get_id() == fiber::id()` and `get_id()` returns the
315 fiber & operator=( fiber && other) noexcept;
318 [[Effects:] [Transfers ownership of the fiber managed by `other` (if any) to
320 [[Postconditions:] [`other->get_id() == fiber::id()` and `get_id()` returns the
327 ~fiber();
330 [[Effects:] [If the fiber is __joinable__, calls std::terminate. Destroys
333 the fiber is still __joinable__. Even if you know that the fiber has completed,
334 you must still call either __join__ or __detach__ before destroying the `fiber`
338 [member_heading fiber..joinable]
343 [[Returns:] [`true` if `*this` refers to a fiber of execution, which may or
348 [member_heading fiber..join]
353 [[Preconditions:] [the fiber is __joinable__.]]
354 [[Effects:] [Waits for the referenced fiber of execution to complete.]]
355 [[Postconditions:] [The fiber of execution referenced on entry has completed.
356 `*this` no longer refers to any fiber of execution.]]
360 [*invalid_argument]: if the fiber is not __joinable__.]]
363 [member_heading fiber..detach]
368 [[Preconditions:] [the fiber is __joinable__.]]
369 [[Effects:] [The fiber of execution becomes detached, and no longer has an
371 [[Postconditions:] [`*this` no longer refers to any fiber of execution.]]
374 [*invalid_argument]: if the fiber is not __joinable__.]]
377 [member_heading fiber..get_id]
379 fiber::id get_id() const noexcept;
382 [[Returns:] [If `*this` refers to a fiber of execution, an instance of
383 __fiber_id__ that represents that fiber. Otherwise returns a
389 [template_member_heading fiber..properties]
395 [[Preconditions:] [`*this` refers to a fiber of execution. [function_link
405 a fiber instance. This method allows access to those user-provided properties.]]
409 [member_heading fiber..swap]
411 void swap( fiber & other) noexcept;
414 [[Effects:] [Exchanges the fiber of execution associated with `*this` and
415 `other`, so `*this` becomes associated with the fiber formerly associated with
423 [function_heading_for swap..fiber]
425 void swap( fiber & l, fiber & r) noexcept;
434 bool operator<( fiber const& l, fiber const& r) noexcept;
470 [endsect] [/ section Class fiber]
474 [section:id Class fiber::id]
476 #include <boost/fiber/fiber.hpp>
518 [[Returns:] [`true` if `*this` and `other` represent the same fiber,
538 implementation-defined total order of `fiber::id` values places `*this` before
583 [endsect] [/ section Class fiber::id]
588 In general, `this_fiber` operations may be called from the ["main] fiber
589 [mdash] the fiber on which function `main()` is entered [mdash] as well as
591 respects the main fiber on each thread can be treated like an
592 explicitly-launched fiber.
598 fibers::fiber::id get_id() noexcept;
611 #include <boost/fiber/operations.hpp>
616 fiber::id get_id() noexcept;
622 executing fiber.]]
628 #include <boost/fiber/operations.hpp>
639 [[Effects:] [Suspends the current fiber until the time point specified by
642 [[Note:] [The current fiber will not resume before `abs_time`, but there are no
653 #include <boost/fiber/operations.hpp>
664 [[Effects:] [Suspends the current fiber until the time duration specified by
667 [[Note:][The current fiber will not resume before `rel_time` has elapsed, but
673 #include <boost/fiber/operations.hpp>
685 [[Note:] [A fiber that calls
692 #include <boost/fiber/operations.hpp>
707 currently running fiber.]]
713 a fiber instance. This function allows access to those user-provided
715 [[Note:] [The first time this function is called from the main fiber of a