Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::AsyncRequestWritableStream< AsyncRequestType > Struct Template Reference
Inheritance diagram for SC::AsyncRequestWritableStream< AsyncRequestType >:
SC::AsyncWritableStream

Public Member Functions

template<typename DescriptorType >
Result init (AsyncBuffersPool &buffersPool, AsyncEventLoop &eventLoop, const DescriptorType &descriptor)
 
void setAutoCloseDescriptor (bool value)
 Automatically closes descriptor during write stream finish event.
 
- Public Member Functions inherited from SC::AsyncWritableStream
Result init (AsyncBuffersPool &buffersPool)
 Emitted when the underlying resource has been closed.
 
constexpr void setWriteQueue (Span< Request > requests)
 Sets the write queue for this writable stream.
 
size_t getWriteQueueSize () const
 Returns the size of write queue.
 
Result write (AsyncBufferView::ID bufferID, Function< void(AsyncBufferView::ID)> cb={})
 Writes a buffer (that must be allocated by the AsyncBuffersPool passed in AsyncWritableStream) When the buffer it will be actually written, AsyncWritableStream::eventWritten will be raised and its reference count will be decreased.
 
Result write (AsyncBufferView &&bufferView, Function< void(AsyncBufferView::ID)> cb={})
 Push a new buffer view to the queue, registering it with the allocator.
 
void end ()
 Ends the writable stream, waiting for all in-flight and queued writes to finish.
 
void destroy ()
 Forcefully destroys the writable stream before calling end event releasing all resources.
 
AsyncBuffersPoolgetBuffersPool ()
 Obtains the buffers pool to access its data.
 
void finishedWriting (AsyncBufferView::ID bufferID, Function< void(AsyncBufferView::ID)> &&cb, Result res)
 Signals that the given buffer (previously queued by write) has been fully written.
 
void resumeWriting ()
 Resumes writing queued requests for this stream.
 
Result unshift (AsyncBufferView::ID bufferID, Function< void(AsyncBufferView::ID)> &&cb)
 Puts back a buffer at the top of the write queue.
 
void emitError (Result error)
 Signals an async error received.
 
void tryAsync (Result potentialError)
 Will emit error if the passed in Result is false.
 
bool isStillWriting () const
 Returns true if this stream is writing something.
 
bool hasBeenDestroyed () const
 Returns true if the stream has been already destroyed (asynchronously through destroy())
 
void setAutoDestroy (bool value)
 If set to true will automatically call .destroy() when Ended state is reached.
 
bool getAutoDestroy () const
 Returns true if stream will automatically call .destroy() when Ended state is reached.
 

Public Attributes

AsyncRequestType request
 
- Public Attributes inherited from SC::AsyncWritableStream
Event< MaxListeners, ResulteventError
 
Event< MaxListeners > eventDrain
 Emitted when an error occurs.
 
Event< MaxListeners > eventFinish
 Emitted when write queue is empty.
 
Event< MaxListeners > eventClose
 Emitted when no more data can be written.
 

Protected Member Functions

virtual Result asyncWrite (AsyncBufferView::ID bufferID, Function< void(AsyncBufferView::ID)> cb) override
 Function that every stream must define to implement its custom write operation.
 
virtual Result asyncDestroyWritable () override
 Function that a writable stream can re-implement to release its internal resources.
 
virtual bool canEndWritable () override
 Allows keeping a writable in ENDING state until it has finished flushing all pending data.
 
void afterWrite (typename AsyncRequestType::Result &result)
 
void finalizeWritableDestruction ()
 
- Protected Member Functions inherited from SC::AsyncWritableStream
void finishedDestroyingWritable ()
 Function that MUST be called by re-implementations of asyncDestroyWritable once they're done.
 
void stop ()
 

Static Protected Member Functions

static void stopWritableCallback (AsyncResult &)
 

Protected Attributes

AsyncEventLoopeventLoop = nullptr
 
AsyncBufferView::ID bufferID
 
bool autoCloseDescriptor = false
 
Function< void(AsyncBufferView::ID)> callback
 

Static Protected Attributes

static Function< void(AsyncResult &)> onStopCallback
 

Additional Inherited Members

- Static Public Attributes inherited from SC::AsyncWritableStream
static constexpr int MaxListeners = 8
 

Member Function Documentation

◆ asyncDestroyWritable()

template<typename AsyncRequestType >
virtual Result SC::AsyncRequestWritableStream< AsyncRequestType >::asyncDestroyWritable ( )
overrideprotectedvirtual

Function that a writable stream can re-implement to release its internal resources.

Note
The re-implementation MUST call finishedDestroyingWritable once it has finished destroying

Reimplemented from SC::AsyncWritableStream.

◆ asyncWrite()

template<typename AsyncRequestType >
virtual Result SC::AsyncRequestWritableStream< AsyncRequestType >::asyncWrite ( AsyncBufferView::ID ,
Function< void(AsyncBufferView::ID)> func )
overrideprotectedvirtual

Function that every stream must define to implement its custom write operation.

Implements SC::AsyncWritableStream.

◆ canEndWritable()

template<typename AsyncRequestType >
virtual bool SC::AsyncRequestWritableStream< AsyncRequestType >::canEndWritable ( )
overrideprotectedvirtual

Allows keeping a writable in ENDING state until it has finished flushing all pending data.

If a writable stream redefines this function it should return true to allow transitioning to ENDED state and return false to keep staying in ENDING state.

Reimplemented from SC::AsyncWritableStream.

◆ setAutoCloseDescriptor()

template<typename AsyncRequestType >
void SC::AsyncRequestWritableStream< AsyncRequestType >::setAutoCloseDescriptor ( bool value)
inline

Automatically closes descriptor during write stream finish event.


The documentation for this struct was generated from the following file: