Module pipes

Pipes.

Pipes allow can be used to communicate tasks. Unlike plain signals, no message can be missed by task doing something else when the signal occurs: writers get blocked when the pipe is full

Usage:

    local pipe = require 'lumen.pipe'
    

Functions

read (piped) Read from a pipe.
write (piped, ...) Write to a pipe.
len (piped) Number of entries in a pipe.
new (size, timeout) Create a new pipe.


Functions

read (piped)
Read from a pipe. Will block on a empty pipe. Also accessible as piped:read()

Parameters:

  • piped the the pipe descriptor to read from.

Returns:

    true,... if data is available, nil,'timeout' on timeout
write (piped, ...)
Write to a pipe. Will block when writing to a full pipe. Also accessible as piped:write()

Parameters:

  • piped the the pipe descriptor to write to.
  • ... elements to write to pipe. All params are stored as a single entry.

Returns:

    true on success, nil,'timeout' on timeout
len (piped)
Number of entries in a pipe. Also accessible as piped:len()

Parameters:

  • piped the the pipe descriptor.

Returns:

    number of entries
new (size, timeout)
Create a new pipe.

Parameters:

  • size maximum number of signals in the pipe
  • timeout timeout for blocking on pipe operations. -1 or nil disable timeout

Returns:

    a pipe descriptor
generated by LDoc 1.4.6 Last updated 2021-07-05 12:15:43