Expand description
Сooperative multitasking module with optional async runtime.
With the fiber module, you can:
- create, run and manage fibers,
- use a synchronization mechanism for fibers, similar to “condition variables” and similar to operating-system
functions such as
pthread_cond_wait()
pluspthread_cond_signal()
, - spawn a fiber based async runtime.
See also:
Re-exports
pub use channel::Channel;
pub use channel::RecvError;
pub use channel::RecvTimeout;
pub use channel::SendError;
pub use channel::SendTimeout;
pub use channel::TryRecvError;
pub use channel::TrySendError;
pub use mutex::Mutex;
pub use async::block_on;
Modules
- Async runtime based on Tarantool fibers. Also includes sycnhronization primitives and useful traits for working with futures.
Structs
- Fiber factory which can be used to configure the properties of the new fiber.
- Conditional variable for cooperative multitasking (fibers).
- FiberDeprecatedWARNING: This api is deprecated due to a number of issues including safety related ones (See doc-comments in
Fiber::cancel
for details). Usefiber::start
,fiber::defer
and/orfiber::Builder
(choose the one most suitable for you). - Fiber attributes container
- A helper struct which is used to store information about a fiber being created. It’s only utility is the generic parameter which are associated with it.
- An owned permission to join a fiber (block on its termination).
- A lock for cooperative multitasking environment
- An RAII implementation of a “scoped lock” of a latch. When this structure is dropped (falls out of scope), the lock will be unlocked.
- This is a typestate helper type representing the state of a
Builder
that hasn’t been assigned a fiber function yet.
Enums
- Possible
check_yield
results.
Constants
- Alignment of the
fiber::Context
struct. - A random number to guard our fiber context from changes by someone else.
- Size of the
fiber::Context
struct. - Current version of the
fiber::Context
struct. This must be bumped every time it’s definition changes. - A value of type
FiberId
which cannot be a valid fiber id. - End of the fiber id range reserved for internal use by tarantool.
- Id of the main fiber, i.e. the first fiber created on the tarantool cord.
Functions
- Cancel the fiber with the given id.
- Calls a function and checks whether it yielded.
- Get
Instant
corresponding to event loop iteration begin time. Uses monotonic clock. - Makes a best effort attempt to check if the given pointer actually points at a valid instance of
Context
struct. - Returns number of context switches of the current fiber.
- Returns number of context switches of the fiber with given id or
None
if fiber with given id wasn’t found. - Creates a new fiber and schedules it for execution, returning a
JoinHandle
for it. - Async version of
defer
. - defer_procDeprecatedCreates a new fiber and schedules it for execution, returning a
JoinHandle
<()>
for it. - Returns
true
if fiber with given id exists. - Yield control to the scheduler.
- Returns id of current fiber.
- Check current fiber for cancellation (it must be checked manually).
- Returns the name of the current fiber.
- Returns the name of the fiber with the given id.
- Returns the name of the fiber with the given id, or
None
if fiber wasn’t found. The name is returned as a slice of bytes, because it is allowed to contain nul bytes. - Reschedule fiber to end of event loop cycle.
- Make it possible or not possible to wakeup the current fiber immediately when it’s cancelled.
- Sets the name of the current fiber.
- Sets the name of the fiber with the given id. Returns
false
if the fiber wasn’t found,true
otherwise. - Put the current fiber to sleep for at least
time
seconds. - Creates a new fiber and yields execution to it immediately, returning a
JoinHandle
for the new fiber. - Async version of
start
. - start_procDeprecatedCreates a new fiber and yields execution to it immediately, returning a [
JoinHandle<()>
] for the new fiber. - Wakeup the fiber with the given id.
- Returns control to the scheduler. Works likewise
fiber::sleep
(Duration::ZERO)
but return error if fiber was canceled by another routine.
Type Aliases
- Type alias for a fiber id.
- LuaJoinHandleDeprecated
- LuaUnitJoinHandleDeprecated
- UnitJoinHandleDeprecated