Module tarantool::fiber

source ·
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() plus pthread_cond_signal(),
  • spawn a fiber based async runtime.

See also:

Re-exports

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).
  • FiberDeprecated
    WARNING: This api is deprecated due to a number of issues including safety related ones (See doc-comments in Fiber::cancel for details). Use fiber::start, fiber::defer and/or fiber::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

Constants

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_procDeprecated
    Creates 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_procDeprecated
    Creates 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