lua.wire.fifo
fifo = wire.fifo(name)
fifo = wire.fifo(handle)
fifo = wire.fifo(opts)
Create or get a fifo. Fifos are not GC'd they must be created and destroyed explicitly.
When called with a name (string) we return a previously created fifo with that name or create a new one ( via house so can take some time ) This is the preferred may to safely create a named fifo.
When called with a handle (number) we return a previously created fifo with that handle ( via house so can take some time ).
We will raise an error if no fifo is found with that handle, so if this function returns you will always have a fifo.
When called with opts (table) we do the following based on the contents.
opts.handle=nil
The handle to use in creation ( so we may reuse an old handle ). If nil we will assign a new one.
opts.name="namedfifo"
The name to use in fifo creation. Usually the only value needed but the creation happens on this thread rather than house so this is a dangerous thing to do.
lua.wire.fifo.peek
bool = fifo:peek()
bool = thread:peek()
Peek and see if there is a memo to pull but do not pull it.
Note that a pull, even immediately after a successful peek has no guarantee to work.
If you wish to actually look at the contents of the memo then pull a memo and then push it back into the fifo. This will of course change the order of memos in the fifo.
lua.wire.fifo.pull
memo = fifo:pull()
memo = thread:pull()
Pull memo out of this fifo.
If this is a memo for us to deal with memo.state will be set to "got"
If this is a result we will return the sent memo with memo.result set to the reply data and the memo state will be changed to "result".
memo may be ignored for now and dealt with later by finding it in wire.memos.
This is useful if you are waiting for a specific reply and want to keep pulling until you find it.
Returns nil if there is no memo available.
May raise an error if we get a reply with an id that we do not recognize.
lua.wire.fifo.push
fifo:push(memo)
thread:push(memo)
Push memo into this fifo.
lua.wire.fifo.wait
fifo:wait(secs)
thread:wait(secs)
Wait upto the given number of seconds for a new memo to arrive in this fifo.