Module tarantool::fiber

source ·
Expand description

Сooperative multitasking module

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() plus pthread_cond_signal().

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

Structs

Fiber factory which can be used to configure the properties of the new fiber.
Conditional variable for cooperative multitasking (fibers).
OBSOLETE: This struct is being deprecated in favour of Immediate, Deferred, etc. due to them being more efficient and idiomatic.
Fiber attributes container
This is a helper type used to configure Fyber with the appropriate behavior for the fiber function that returns a value.
This is a helper type used to configure Fyber with the appropriate behavior for the fiber procedure (function which doens’t return a value).
A handle to a fiber.
An owned permission to join on an immediate 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.
LuaFiber
LuaFiberFunc
LuaFiberProc
LuaJoinHandle
LuaUnitJoinHandle
This is a typestate helper type representing the state of a Builder that hasn’t been assigned a fiber function yet.
An owned permission to join on an immediate fiber (block on its termination).

Enums

Possible check_yield results.

Traits

Callee Types implementing this trait represent Fyber configurations relating to the kind of the fiber function. Currently only 2 kinds of functions are supported:
Invocation Types implementing this trait represent Fyber configurations relating to kinds of fiber invocations. Currently there are 2 kinds of invocations supported:
LuaCallee

Functions

Calls a function and checks whether it yielded.
Report loop begin time as double (cheap). Uses monotonic clock.
Report loop begin time as 64-bit int. Uses monotonic clock.
Returns the number of context switches of the calling fiber.
Creates a new fiber and schedules it for execution, returning a LuaJoinHandle for it.
Async version of defer.
Creates a new proc fiber and schedules it for execution, returning a LuaUnitJoinHandle for it.
Yield control to the scheduler.
Check current fiber for cancellation (it must be checked manually).
Reschedule fiber to end of event loop cycle.
Make it possible or not possible to wakeup the current fiber immediately when it’s cancelled.
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.
Creates a new proc fiber and yields execution to it immediately, returning a UnitJoinHandle for the new fiber.
Report loop begin time as double (cheap).
Report loop begin time as 64-bit int.
Returns control to the scheduler. Works likewise fiber::sleep(Duration::ZERO) but return error if fiber was canceled by another routine.