Module irccd.thread.pipe
Pipes.
Note: Pipes are very experimental and not widely tested yet.
This API provides functions to communicate between threads and Lua plugins.
Functions
get (name) | Get (or create) a new pipe. |
Class Pipe
Pipe:push (data) | Push some data to the pipe. |
Pipe:first () | Get the first value. |
Pipe:last () | Get the last value. |
Pipe:wait (timeout) | Wait for data. |
Pipe:list () | Get all the data. |
Pipe:clear () | Remove all values from the pipe. |
Pipe:pop () | Remove the first value. |
Functions
- get (name)
-
Get (or create) a new pipe.
Parameters:
- name the name of the pipe
Returns:
-
the created pipe
Class Pipe
- Pipe:push (data)
-
Push some data to the pipe.
This function also signal availability to waiting threads.
Note: userdata, function are not supported as parameters.Parameters:
- data the data to pass
- Pipe:first ()
-
Get the first value.
This function does not remove the value from the pipe.
Returns:
-
the first value
- Pipe:last ()
-
Get the last value.
This function does not remove the value from the pipe.
Returns:
-
the last value
- Pipe:wait (timeout)
-
Wait for data.
Parameters:
- timeout an optional timeout in millisecond, default 0.
Returns:
-
false if the timeout expired.
- Pipe:list ()
-
Get all the data.
The iterator returns one value which may be any type, except
function and userdata. It removes all values from the pipe.
Returns:
-
an iterator
Usage:
-- Get all data for v in p:list() do print(tostring(v)) end
- Pipe:clear ()
- Remove all values from the pipe.
- Pipe:pop ()
- Remove the first value.