New fiber API - tsafin/tarantool GitHub Wiki

join()

We need to be able to syncrhonously wait till a fiber ends (already possible with checking for fiber:status() and grab the results its main function returns.

Something like:

local v1, v2, v3 = fiber:join()

fiber:join() returns what the function, passed to fiber:create() has returned.

It is also necessary :

  1. to make it possible to call fiber:join() a long time after the fiber main function has ended
  2. to make fiber:join() callable multiple times (it should return the same all the time). QQQ (@kostja this would leak memory)
  3. make fiber:join() callable from multiple fibers, and, if called before the subject fiber has finished work, the caller is suspended until the subject fiber has ended.

Additinally:

  1. if the subject fiber ended with an exception, fiber:join() should throw the same exception
  2. fiber:join() should be callable on a fiber which has no variables referencing it, but was obtained with fiber.find()
  3. fiber:join() on a system fiber should be safe (should throw an error)

Fiber mailboxes

Note: mailboxes seem to be obsolete with fiber local storage.

Each fiber should have a built-in fiber-ipc-channel.

This simplifies the following matters:

  1. Sending a mesasge to the fiber: fiber.sendmsg{} could be used.
  2. Receiving a message: fiber.recvmsg( [ timeout ] )
  3. An attemt to get another fiber s message should lead to an exception
  4. A channel should be created on demand, since many fibers will not use it.
  5. The size of the fiber should be configurable, set to 1 by default.
  6. It should be possible to change the size of the channel. If the new size is below the current amount of messages in the channel, it should throw an error.
  7. The channel should not go away when fiber variable goes away.