folly::AsyncPipeWriter

Write to a pipe in an async manner.

Synopsis

Declared in <folly/io/async/AsyncPipe.h>

class AsyncPipeWriter
    : public EventHandler
    , public AsyncWriter
    , public DelayedDestruction

Base Classes

NameDescription
EventHandlerThe EventHandler class is used to asynchronously wait for events on a file descriptor.
AsyncWriterInterface for the write side of an asynchronous transport.
DelayedDestructionDelayedDestruction is a helper class to ensure objects are not deleted while they still have functions executing in a higher stack frame.

Types

NameDescription
Destructor Helper class to allow DelayedDestruction classes to be used with std::shared_ptr.
DestructorGuard Classes should create a DestructorGuard object on the stack in any function that may invoke callback functions.
IntrusivePtr This smart pointer is a convenient way to manage a concrete DelayedDestructorBase child. It can replace the equivalent raw pointer and provide automatic memory management.
RXZerocopyParams Parameters controlling receive-side zero-copy.
ReleaseIOBufCallback Callback invoked to release ownership of an IOBuf after a write.
WriteCallback Callback interface used to report the result of a write.

Type Aliases

NameDescription
UniquePtr Smart pointer type that destroys the writer through DelayedDestruction.
ZeroCopyEnableFunc Predicate deciding whether a given buffer should use zero-copy writes.

Enums

NameDescription
EventFlags Bitset flags describing the I/O events a handler can wait for.

Member Functions

NameDescription
AsyncPipeWriter [constructor]Construct an AsyncPipeWriter for the given pipe file descriptor.
operator= Assignment operators
activateEvent Make an event active.
attachEventBase Attach the handler to a EventBase.
changeHandlerFD Change the file descriptor that this handler is associated with.
closeNow Close the pipe immediately, and fail all pending writes
closeOnEmpty Notify the pipe to close as soon as all pending writes complete
closed Returns true if the pipe is closed
destroy [virtual]destroy() requests destruction of the object.
detachEventBase Detach the handler from its EventBase.
getDestroyPending Returns whether destruction has been requested but deferred.
getRXZeroCopy [virtual]Return whether receive-side zero-copy is enabled.
getRegisteredEvents Return the set of events that we're currently registered for.
getZeroCopy [virtual]Return whether zero-copy writes are enabled.
handlerReady [virtual]handlerReady() is invoked when the handler is ready.
hasPendingWrites Return true if there are currently writes pending (eg: the pipe is blocked for writing)
initHandler Attach the handler to a EventBase, and change the file descriptor.
isHandlerRegistered Returns true if the handler is currently registered.
isPending Returns true if the handler is registered but has not yet fired.
registerHandler Register the handler.
registerInternalHandler Register the handler as an internal event.
setCloseCallback Set a special hook to close the socket (otherwise, will call close())
setEdgeTriggered If supported by the backend updates the event to be edge-triggered. Returns true iff the update was successful.
setRXZeroCopy [virtual]Enable or disable receive-side zero-copy using the given parameters.
setZeroCopy [virtual]Enable or disable zero-copy writes.
setZeroCopyEnableFunc [virtual]Set the predicate deciding when zero-copy writes are used.
setZeroCopyEnableThreshold [virtual]Set the minimum write size, in bytes, for using zero-copy writes.
unregisterHandler Unregister the handler, if it is registered.
write write overloads
writeChain writeChain overloads
writev writev overloads

Static Member Functions

NameDescription
newWriter Create a new AsyncPipeWriter managed by a UniquePtr.

Protected Member Functions

NameDescription
getDestructorGuardCount Get the number of DestructorGuards currently protecting this object.
onDelayedDestroy [virtual]Implement onDelayedDestroy in subclasses. onDelayedDestroy() is invoked when the object is potentially being destroyed.