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 :
- to make it possible to call
fiber:join()
a long time after the fiber main function has ended - to make
fiber:join()
callable multiple times (it should return the same all the time). QQQ (@kostja this would leak memory) - 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:
- if the subject fiber ended with an exception,
fiber:join()
should throw the same exception fiber:join()
should be callable on a fiber which has no variables referencing it, but was obtained withfiber.find()
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:
- Sending a mesasge to the fiber:
fiber.sendmsg{}
could be used. - Receiving a message:
fiber.recvmsg( [ timeout ] )
- An attemt to get another fiber s message should lead to an exception
- A channel should be created on demand, since many fibers will not use it.
- The size of the fiber should be configurable, set to 1 by default.
- 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.
- The channel should not go away when fiber variable goes away.