Async source abstraction emitting data events in caller provided byte buffers.
More...
#include <AsyncStreams.h>
|
|
Event< MaxListeners, Result > | eventError |
| |
| Event< MaxListeners, AsyncBufferView::ID > | eventData |
| | Emitted when an error occurs.
|
| |
| Event< MaxListeners > | eventEnd |
| | Emitted when a new buffer has been read.
|
| |
| Event< MaxListeners > | eventClose |
| | Emitted when there is no more data.
|
| |
|
|
static constexpr int | MaxListeners = 8 |
| |
|
| virtual Result | asyncRead ()=0 |
| | Function that every stream must define to implement its custom read operation.
|
| |
| virtual Result | asyncDestroyReadable () |
| | Function that a readable stream can re-implement to release its internal resources.
|
| |
| Result | finishedDestroyingReadable () |
| | Called from inside asyncDestroy to transition from Destroying to Destroyed state (emitting eventClose)
|
| |
Async source abstraction emitting data events in caller provided byte buffers.
After AsyncReadableStream::start it will start emitting AsyncReadableStream::eventData with buffers. User must provide a custom async red implementation in AsyncReadableStream::asyncRead. The stream must be paused when the AsyncBuffersPool is full (use AsyncReadableStream::getBufferOrPause). Once the stream is ended, it will emit AsyncReadableStream::eventEnd and it cannot be used further. AsyncReadableStream::eventError will be emitted when an error occurs in any phase.
◆ asyncDestroyReadable()
| virtual Result SC::AsyncReadableStream::asyncDestroyReadable |
( |
| ) |
|
|
protectedvirtual |
◆ asyncRead()
| virtual Result SC::AsyncReadableStream::asyncRead |
( |
| ) |
|
|
protectedpure virtual |
◆ destroy()
| void SC::AsyncReadableStream::destroy |
( |
| ) |
|
Forcefully destroys the readable stream before calling end event releasing all resources.
- Note
- It's safe to call destroy in any state and also when already destroyed (it's idempotent)
◆ emitError()
| void SC::AsyncReadableStream::emitError |
( |
Result | error | ) |
|
Signals an async error received.
◆ finishedDestroyingReadable()
| Result SC::AsyncReadableStream::finishedDestroyingReadable |
( |
| ) |
|
|
protected |
Called from inside asyncDestroy to transition from Destroying to Destroyed state (emitting eventClose)
◆ getAutoDestroy()
| bool SC::AsyncReadableStream::getAutoDestroy |
( |
| ) |
const |
|
inlinenodiscard |
Returns true if stream will automatically call .destroy() when Ended state is reached.
◆ getBufferOrPause()
Returns an unused buffer from pool or pauses the stream if none is available.
◆ getBuffersPool()
◆ getReadQueueSize()
| size_t SC::AsyncReadableStream::getReadQueueSize |
( |
| ) |
const |
|
inlinenodiscard |
Returns the size of read queue.
◆ hasBeenDestroyed()
| bool SC::AsyncReadableStream::hasBeenDestroyed |
( |
| ) |
const |
|
inlinenodiscard |
Returns true if the stream has been already destroyed (asynchronously through destroy())
◆ init()
◆ isEnded()
| bool SC::AsyncReadableStream::isEnded |
( |
| ) |
const |
|
inlinenodiscard |
Returns true if the stream is ended (AsyncReadableStream::end has been called)
◆ pause()
| void SC::AsyncReadableStream::pause |
( |
| ) |
|
Pauses the readable stream (that can be later resumed)
◆ push()
◆ pushEnd()
| void SC::AsyncReadableStream::pushEnd |
( |
| ) |
|
◆ reactivate()
| void SC::AsyncReadableStream::reactivate |
( |
bool | doReactivate | ) |
|
◆ resumeReading()
| void SC::AsyncReadableStream::resumeReading |
( |
| ) |
|
◆ setAutoDestroy()
| void SC::AsyncReadableStream::setAutoDestroy |
( |
bool | value | ) |
|
|
inline |
If set to true will automatically call .destroy() when Ended state is reached.
◆ setReadQueue()
| void SC::AsyncReadableStream::setReadQueue |
( |
Span< Request > | requests | ) |
|
|
inlineconstexpr |
Sets the read queue for this readable stream.
◆ start()
| Result SC::AsyncReadableStream::start |
( |
| ) |
|
Starts the readable stream, that will emit eventData.
◆ unshift()
Push back a buffer to the front of the read queue (e.g. for un-consumed data)
◆ eventClose
| Event<MaxListeners> SC::AsyncReadableStream::eventClose |
Emitted when there is no more data.
◆ eventData
Emitted when an error occurs.
◆ eventEnd
| Event<MaxListeners> SC::AsyncReadableStream::eventEnd |
Emitted when a new buffer has been read.
The documentation for this struct was generated from the following file: