Модуль fiber | Tarantool
Документация на русском языке
поддерживается сообществом
Модуль fiber

Модуль fiber

struct fiber

Fiber - contains information about fiber

struct fiber *fiber_new(const char *name, fiber_func f)
typedef int (*fuber_func)(va_list)

Create a new fiber.

Takes a fiber from 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.

Параметры:
  • char* name (const) – string with fiber name
  • f (fiber_func) – func for run inside fiber

See also: fiber_start()

void fiber_yield(void)

Return control to another fiber and wait until it’ll be woken.

See also: fiber_wakeup()

void fiber_start(struct fiber *callee, ...)

Start execution of created fiber.

Параметры:
  • fiber* callee (struct) – fiber to start
  • ... – arguments to start the fiber with
void fiber_wakeup(struct fiber *f)

Interrupt a synchronous wait of a fiber

Параметры:
  • fiber* f (struct) – fiber to be woken up
void fiber_cancel(struct fiber *f)

Cancel the subject fiber (set FIBER_IS_CANCELLED flag)

If target fiber’s flag FIBER_IS_CANCELLABLE set, then it would be woken up (maybe prematurely). Then current fiber yields until the target fiber is dead (or is woken up by fiber_wakeup()).

Параметры:
  • fiber* f (struct) – fiber to be cancelled
bool fiber_set_cancellable(bool yesno)

Make it possible or not possible to wakeup the current fiber immediately when it’s cancelled.

Параметры:
  • fiber* f (struct) – fiber
  • yesno (bool) – status to set
Результат:

previous state

void fiber_set_joinable(struct fiber *fiber, bool yesno)

Set fiber to be joinable (false by default).

Параметры:
  • fiber* f (struct) – 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.

Параметры:
  • fiber* f (struct) – fiber to be woken up

Before: FIBER_IS_JOINABLE flag 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()

Check current fiber for cancellation (it must be checked manually).

double fiber_time(void)

Report loop begin time as double (cheap).

uint64_t fiber_time64(void)

Report loop begin time as 64-bit int.

void fiber_reschedule(void)

Reschedule fiber to end of event loop cycle.

struct slab_cache
struct slab_cache *cord_slab_cache(void)

Return slab_cache suitable to use with tarantool/small library

Нашли ответ на свой вопрос?
Обратная связь