Module fiber
- 
typedef int (*fiber_func)(va_list)¶
- Function to run inside a fiber. 
- 
fiber *fiber_new(const char *name, fiber_func f)¶
- Create a new fiber. - Takes a fiber from the fiber cache, if it’s not empty. Can fail only if there is not enough memory for the fiber structure or fiber stack. - The created fiber automatically returns itself to the fiber cache when its «main» function completes. - Параметры: - name (const char*) – string with fiber name
- f (fiber_func) – func for run inside fiber
 - See also: fiber_start() 
- 
fiber *fiber_new_ex(const char *name, const struct fiber_attr *fiber_attr, fiber_func f)¶
- Create a new fiber with defined attributes. - Can fail only if there is not enough memory for the fiber structure or fiber stack. - The created fiber automatically returns itself to the fiber cache if has a default stack size when its «main» function completes. - Параметры: - name (const char*) – string with fiber name
- fiber_attr (const struct fiber_attr*) – fiber attributes container
- f (fiber_func) – function to run inside the fiber
 - See also: fiber_start() 
- 
void fiber_start(struct fiber *callee, ...)¶
- Start execution of created fiber. - Параметры: - callee (struct fiber*) – fiber to start
- ... – arguments to start the fiber with
 
- 
void fiber_yield(void)¶
- Return control to another fiber and wait until it’ll be woken. - See also: fiber_wakeup() 
- 
void fiber_wakeup(struct fiber *f)¶
- Interrupt a synchronous wait of a fiber - Параметры: - f (struct fiber*) – fiber to be woken up
 
- 
void fiber_cancel(struct fiber *f)¶
- Cancel the subject fiber. - Cancellation is asynchronous. Use fiber_join() to wait for the cancellation to complete. - After - fiber_cancel()is called, the fiber may or may not check whether it was cancelled. If the fiber does not check it, it cannot ever be cancelled.- Параметры: - f (struct fiber*) – fiber to be cancelled
 
- 
bool fiber_set_cancellable(bool yesno)¶
- Deprecated since 2.11.0. Make it possible or not possible to wakeup the current fiber immediately when it’s cancelled. - Параметры: - f (struct fiber*) – fiber
- yesno (bool) – status to set
 - Результат: - previous state 
- 
void fiber_set_joinable(struct fiber *fiber, bool yesno)¶
- Set fiber to be joinable ( - falseby default).- Параметры: - f (struct fiber*) – fiber
- yesno (bool) – status to set
 
- 
void fiber_join(struct fiber *f)¶
- Wait until the fiber is dead and then move its execution status to the caller. The fiber must not be detached. - Параметры: - f (struct fiber*) – fiber to be woken up
 - Before: - FIBER_IS_JOINABLEflag is set.- See also: fiber_set_joinable() 
- 
void fiber_sleep(double s)¶
- Put the current fiber to sleep for at least „s“ seconds. - Параметры: - s (double) – time to sleep
 - Note: this is a cancellation point. - See also: fiber_is_cancelled() 
- 
bool fiber_is_cancelled(void)¶
- Check current fiber for cancellation (it must be checked manually). 
- 
double fiber_time(void)¶
- Report loop begin time as double (cheap). 
- 
int64_t fiber_time64(void)¶
- Report loop begin time as 64-bit int. Uses real time clock. 
- 
double fiber_clock(void)¶
- Report loop begin time as double (cheap). Uses monotonic clock. 
- 
int64_t fiber_clock64(void)¶
- Report loop begin time as 64-bit int. Uses monotonic clock. 
- 
void fiber_reschedule(void)¶
- Reschedule fiber to end of event loop cycle. 
- 
type slab_cache¶
- 
struct slab_cache *cord_slab_cache(void)¶
- Return - slab_cachesuitable to use with- tarantool/smalllibrary
- 
type fiber_attr¶
- 
void fiber_attr_new(void)¶
- Create a new fiber attributes container and initialize it with default parameters. - Can be used for creating many fibers: corresponding fibers will not take ownership. 
- 
void fiber_attr_delete(struct fiber_attr *fiber_attr)¶
- Delete the - fiber_attrand free all allocated resources. This is safe when fibers created with this attribute still exist.- Параметры: - fiber_attribute (struct fiber_attr*) – fiber attributes container
 
- 
int fiber_attr_setstacksize(struct fiber_attr *fiber_attr, size_t stack_size)¶
- Set the fiber’s stack size in the fiber attributes container. - Параметры: - fiber_attr (struct fiber_attr*) – fiber attributes container
- stack_size (size_t) – stack size for new fibers (in bytes)
 - Результат: - 0 on success - Результат: - -1 on failure (if - stack_sizeis smaller than the minimum allowable fiber stack size)
- 
size_t fiber_attr_getstacksize(struct fiber_attr *fiber_attr)¶
- Get the fiber’s stack size from the fiber attributes container. - Параметры: - fiber_attr (struct fiber_attr*) – fiber attributes container, or NULL for default
 - Результат: - stack size (in bytes) 
- 
type fiber_cond¶
- A conditional variable: a synchronization primitive that allow fibers in Tarantool’s cooperative multitasking environment to yield until some predicate is satisfied. - Fiber conditions have two basic operations – «wait» and «signal», – where «wait» suspends the execution of a fiber (i.e. yields) until «signal» is called. - Unlike - pthread_cond,- fiber_conddoesn’t require mutex/latch wrapping.
- 
struct fiber_cond *fiber_cond_new(void)¶
- Create a new conditional variable. 
- 
void fiber_cond_delete(fiber_cond *cond)¶
- Delete the conditional variable. - Note: behavior is undefined if there are fibers waiting for the conditional variable. - Параметры: - cond (struct fiber_cond*) – conditional variable to delete
 
- 
void fiber_cond_signal(struct fiber_cond *cond);¶
- Wake up one (any) of the fibers waiting for the conditional variable. - Does nothing if no one is waiting. - Параметры: - cond (struct fiber_cond*) – conditional variable
 
- 
void fiber_cond_broadcast(struct fiber_cond *cond);¶
- Wake up all fibers waiting for the conditional variable. - Does nothing if no one is waiting. - Параметры: - cond (struct fiber_cond*) – conditional variable
 
- 
int fiber_cond_wait_timeout(struct fiber_cond *cond, double timeout)¶
- Suspend the execution of the current fiber (i.e. yield) until fiber_cond_signal() is called. - Like - pthread_cond,- fiber_condcan issue spurious wake ups caused by explicit fiber_wakeup() or fiber_cancel() calls. It is highly recommended to wrap calls to this function into a loop and check the actual predicate and fiber_is_cancelled() on every iteration.- Параметры: - cond (struct fiber_cond*) – conditional variable
- timeout (double) – timeout in seconds
 - Результат: - 0 on fiber_cond_signal() call or a spurious wake up - Результат: - -1 on timeout, and the error code is set to „TimedOut“ 
- 
int fiber_cond_wait(struct fiber_cond *cond)¶
- Shortcut for fiber_cond_wait_timeout().