Starts a file write operation, writing bytes to a file (or pipe). More...
#include <Async.h>
Classes | |
| struct | CompletionData |
| struct | Result |
Public Member Functions | |
| SC::Result | start (AsyncEventLoop &eventLoop, Span< Span< const char > > data) |
| Sets async request members and calls AsyncEventLoop::start. | |
| SC::Result | start (AsyncEventLoop &eventLoop, Span< const char > data) |
| Sets async request members and calls AsyncEventLoop::start. | |
| uint64_t | getOffset () const |
| Returns the last offset set with AsyncFileWrite::setOffset. | |
| void | setOffset (uint64_t fileOffset) |
| Sets the offset in bytes at which start writing. | |
| Result | start (AsyncEventLoop &eventLoop) |
| Shortcut for AsyncEventLoop::start. | |
Public Member Functions inherited from SC::AsyncRequest | |
| void | setDebugName (const char *newDebugName) |
| void | executeOn (AsyncSequence &sequence) |
| Adds the request to be executed on a specific AsyncSequence. | |
| Result | executeOn (AsyncTaskSequence &task, ThreadPool &pool) |
| Adds the request to be executed on a specific AsyncTaskSequence. | |
| void | disableThreadPool () |
| Disables the thread-pool usage for this request. | |
| AsyncRequest (Type type) | |
| Constructs a free async request of given type. | |
| Result | stop (AsyncEventLoop &eventLoop, Function< void(AsyncResult &)> *afterStopped=nullptr) |
| Ask to stop current async operation. | |
| bool | isFree () const |
Returns true if this request is free. | |
| bool | isCancelling () const |
Returns true if this request is being cancelled. | |
| bool | isActive () const |
Returns true if this request is active or being reactivated. | |
| Type | getType () const |
| Returns request type. | |
| Result | start (AsyncEventLoop &eventLoop) |
| Shortcut for AsyncEventLoop::start. | |
| void | setUserFlags (uint16_t externalFlags) |
| Sets user flags, holding some meaningful data for the caller. | |
| uint16_t | getUserFlags () const |
| Gets user flags, holding some meaningful data for the caller. | |
| Function< void(AsyncResult &)> * | getCloseCallback () |
| Returns currently set close callback (if any) passed to AsyncRequest::stop. | |
| const Function< void(AsyncResult &)> * | getCloseCallback () const |
Public Attributes | |
| Function< void(Result &)> | callback |
| Callback called when descriptor is ready to be written with more data. | |
| FileDescriptor::Handle | handle |
| The file/pipe descriptor to write data to. | |
| Span< const char > | buffer |
| The read-only span of memory where to read the data from. | |
| Span< Span< const char > > | buffers |
| The read-only spans of memory where to read the data from. | |
| bool | singleBuffer = true |
| Controls if buffer or buffers will be used. | |
Public Attributes inherited from SC::AsyncRequest | |
| AsyncRequest * | next = nullptr |
| AsyncRequest * | prev = nullptr |
Friends | |
| struct | AsyncEventLoop |
Additional Inherited Members | |
Public Types inherited from SC::AsyncRequest | |
| enum class | Type : uint8_t { LoopTimeout , LoopWakeUp , LoopWork , ProcessExit , SocketAccept , SocketConnect , SocketSend , SocketSendTo , SocketReceive , SocketReceiveFrom , FileRead , FileWrite , FilePoll , FileSystemOperation } |
| Type of async request. More... | |
Protected Member Functions inherited from SC::AsyncRequest | |
| Result | checkState () |
| void | queueSubmission (AsyncEventLoop &eventLoop) |
| AsyncTaskSequence * | getTask () |
Protected Attributes inherited from SC::AsyncRequest | |
| AsyncSequence * | sequence = nullptr |
Starts a file write operation, writing bytes to a file (or pipe).
Callback will be called when the file is ready to receive more bytes to write.
Call AsyncRequest::executeOn to set a thread pool if this is a buffered file and not a pipe. This is important on APIs with blocking behaviour on buffered file I/O (all apis with the exception of io_uring).
File library can be used to open the file and obtain a blocking or non-blocking file descriptor handle.
O_DIRECT or Windows FILE_FLAG_WRITE_THROUGH & FILE_FLAG_NO_BUFFERING should instead avoid using the Task parameter for best performance.When not using the Task remember to:
false)
|
inline |
Returns the last offset set with AsyncFileWrite::setOffset.
|
inline |
Sets the offset in bytes at which start writing.
| Result SC::AsyncRequest::start | ( | AsyncEventLoop & | eventLoop | ) |
Shortcut for AsyncEventLoop::start.
| SC::Result SC::AsyncFileWrite::start | ( | AsyncEventLoop & | eventLoop, |
| Span< const char > | data ) |
Sets async request members and calls AsyncEventLoop::start.
| SC::Result SC::AsyncFileWrite::start | ( | AsyncEventLoop & | eventLoop, |
| Span< Span< const char > > | data ) |
Sets async request members and calls AsyncEventLoop::start.
| Span<const char> SC::AsyncFileWrite::buffer |
The read-only span of memory where to read the data from.
The read-only spans of memory where to read the data from.
Callback called when descriptor is ready to be written with more data.
| FileDescriptor::Handle SC::AsyncFileWrite::handle |
The file/pipe descriptor to write data to.
Use SC::FileDescriptor or SC::PipeDescriptor to open it.
| bool SC::AsyncFileWrite::singleBuffer = true |
Controls if buffer or buffers will be used.