Home
Base module

Pipe

Named pipe / stdio stream built on uv_pipe_t.

Pipe

#include <icy/pipe.h>
class Pipe

Defined in src/base/include/icy/pipe.h:27

Inherits: Stream< uv_pipe_t >

Named pipe / stdio stream built on uv_pipe_t.

Suitable for inter-process communication and for wrapping process stdio (stdin/stdout/stderr). IPC mode allows passing stream handles between processes over the pipe.

List of all members

NameKindOwner
PipefunctionDeclared here
~PipefunctionDeclared here
initfunctionDeclared here
readStartfunctionDeclared here
ReadvariableInherited from Stream
StreamfunctionInherited from Stream
~StreamfunctionInherited from Stream
closefunctionInherited from Stream
shutdownfunctionInherited from Stream
writefunctionInherited from Stream
writeOwnedfunctionInherited from Stream
setHighWaterMarkfunctionInherited from Stream
writefunctionInherited from Stream
streamfunctionInherited from Stream
_buffervariableInherited from Stream
_startedvariableInherited from Stream
_highWaterMarkvariableInherited from Stream
_writeReqFreevariableInherited from Stream
_ownedWriteReqFreevariableInherited from Stream
readStartfunctionInherited from Stream
readStopfunctionInherited from Stream
onReadfunctionInherited from Stream
allocWriteReqfunctionInherited from Stream
freeWriteReqfunctionInherited from Stream
allocOwnedWriteReqfunctionInherited from Stream
freeOwnedWriteReqfunctionInherited from Stream
canQueueWritefunctionInherited from Stream
HandletypedefInherited from Stream
HandlefunctionInherited from Handle
~HandlefunctionInherited from Handle
initfunctionInherited from Handle
invokefunctionInherited from Handle
invokeOrThrowfunctionInherited from Handle
closefunctionInherited from Handle
reffunctionInherited from Handle
unreffunctionInherited from Handle
initializedfunctionInherited from Handle
activefunctionInherited from Handle
closingfunctionInherited from Handle
closedfunctionInherited from Handle
errorfunctionInherited from Handle
setErrorfunctionInherited from Handle
setUVErrorfunctionInherited from Handle
setAndThrowErrorfunctionInherited from Handle
throwLastErrorfunctionInherited from Handle
loopfunctionInherited from Handle
resetfunctionInherited from Handle
getfunctionInherited from Handle
tidfunctionInherited from Handle
contextfunctionInherited from Handle
setCloseCleanupfunctionInherited from Handle
clearCloseCleanupfunctionInherited from Handle
assertThreadfunctionInherited from Handle
_loopvariableInherited from Handle
_contextvariableInherited from Handle
_tidvariableInherited from Handle
_errorvariableInherited from Handle
onErrorfunctionInherited from Handle
onClosefunctionInherited from Handle
HandlefunctionInherited from Handle
operator=functionInherited from Handle
HandlefunctionInherited from Handle
operator=functionInherited from Handle
TypetypedefInherited from Handle

Inherited from Stream

KindNameDescription
variableReadEmitted when data has been received from the peer.
functionStream inlineConstruct the stream bound to loop with a 64 KiB read buffer.
function~Stream virtual inlineDestroy the stream, stopping reads and freeing pooled write requests.
functionclose virtual inline overrideCloses and resets the stream handle. This will close the active socket/pipe and destroy the handle.
functionshutdown inlineSend a TCP/pipe shutdown request to the connected peer.
functionwrite inlineWrite len bytes from data to the stream.
functionwriteOwned inlineWrite an owned payload buffer to the stream.
functionsetHighWaterMark inlineSet the high water mark for the write queue (default 16MB). When the write queue exceeds this size, write() returns false.
functionwrite inlineWrite len bytes from data together with a stream handle over an IPC pipe (uses uv_write2).
functionstream inlineReturn the underlying uv_stream_t pointer cast from the native handle.
variable_buffer
variable_started
variable_highWaterMark16MB default write queue limit
variable_writeReqFreeFreelist for write requests.
variable_ownedWriteReqFreeFreelist for owned write requests.
functionreadStart virtual inlineBegin reading from the stream by registering libuv read callbacks.
functionreadStop virtual inlineStop reading from the stream.
functiononRead virtual inlineCalled by handleRead when len bytes of data arrive.
functionallocWriteReq inlineReturn a uv_write_t from the freelist, or allocate a new one if the pool is empty.
functionfreeWriteReq inlineReturn req to the freelist, or delete it if the pool is at capacity.
functionallocOwnedWriteReq inline
functionfreeOwnedWriteReq inline
functioncanQueueWrite inline
typedefHandle

Inherited from Handle

KindNameDescription
functionHandle inlineConstruct the handle bound to the given event loop.
function~Handle virtual inline
functioninit inlineInitialize the underlying libuv handle by calling f with the loop, the raw handle pointer, and any additional args.
functioninvoke inlineInvoke a libuv function f with args on the initialized handle.
functioninvokeOrThrow inlineInvoke a libuv function f with args, throwing on failure.
functionclose virtual inlineClose and destroy the handle.
functionref inlineRe-reference the handle with the event loop after a previous [unref()](icy-uv-Handle.html#unref).
functionunref inlineUnreference the handle from the event loop.
functioninitialized const inlineReturn true if the handle has been successfully initialized via [init()](icy-uv-Handle.html#init-8).
functionactive virtual const inlineReturn true when the handle is active (libuv uv_is_active).
functionclosing virtual const inlineReturn true if uv_close has been called and the handle is awaiting its close callback (libuv uv_is_closing).
functionclosed virtual const inlineReturn true if the handle has been fully closed (context released).
functionerror const inlineReturn the last error set on this handle, or a default-constructed [Error](icy-Error.html#error) if no error has occurred.
functionsetError virtual inlineSet the error state and invoke [onError()](icy-uv-Handle.html#onerror).
functionsetUVError inlineTranslate a libuv error code into an [Error](icy-Error.html#error) and call [setError()](icy-uv-Handle.html#seterror-1).
functionsetAndThrowError inlineSet the error state from a libuv error code and throw a std::runtime_error.
functionthrowLastError inlineThrow a std::runtime_error if the handle currently holds an error.
functionloop const inlineReturn the event loop this handle is bound to.
functionreset inlineClose the current handle (if open) and allocate a fresh [Context](icy-uv-Context.html#context-2), leaving the handle ready to be re-initialized via [init()](icy-uv-Handle.html#init-8).
functionget const inlineReturn the raw libuv handle pointer cast to [Handle](icy-uv-Handle.html#handle-6).
functiontid const inlineReturn the ID of the thread that constructed this handle.
functioncontext const inlineReturn the raw [Context](icy-uv-Context.html#context-2) that owns the libuv handle memory.
functionsetCloseCleanup inline
functionclearCloseCleanup inline
functionassertThread const inlineThrow std::logic_error if called from any thread other than the thread that constructed this handle.
variable_loop
variable_context
variable_tid
variable_error
functiononError virtual inlineCalled by [setError()](icy-uv-Handle.html#seterror-1) after the error state has been updated.
functiononClose virtual inlineCalled by [close()](icy-uv-Handle.html#close-18) after the context has been released.
functionHandleNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionHandleDeleted constructor.
functionoperator=Deleted assignment operator.
typedefTypeDefine the native handle type.

Public Methods

ReturnNameDescription
PipeConstruct a [Pipe](#pipe) bound to loop without initializing the libuv handle.
~Pipe virtualDestroy the pipe, stopping reads and closing the handle.
voidinit virtualInitialize the underlying uv_pipe_t handle.
boolreadStart virtual overrideStart reading from the pipe.

Pipe

Pipe(uv::Loop * loop = uv::defaultLoop())

Defined in src/base/include/icy/pipe.h:35

Construct a [Pipe](#pipe) bound to loop without initializing the libuv handle.

Call [init()](#init-3) before performing any I/O.

Parameters

  • loop Event loop to associate with. Defaults to the process-wide default loop.

~Pipe

virtual

virtual ~Pipe()

Defined in src/base/include/icy/pipe.h:38

Destroy the pipe, stopping reads and closing the handle.


init

virtual

virtual void init(bool ipc = false)

Defined in src/base/include/icy/pipe.h:46

Initialize the underlying uv_pipe_t handle.

Must be called before [readStart()](#readstart) or any write operations.

Parameters

  • ipc Set to true to enable IPC mode, which allows sending and receiving stream handles alongside data via [write()](icy-Stream.html#write-16).

readStart

virtual override

virtual bool readStart() override

Defined in src/base/include/icy/pipe.h:54

Start reading from the pipe.

Delegates to [Stream](icy-Stream.html#stream)<uv_pipe_t>::[readStart()](#readstart). Emits the Read signal as data arrives.

Returns

true if uv_read_start was called successfully.

Reimplements