Executes work in a thread pool and then invokes a callback on the event loop thread. More...
#include <Async.h>
Public Types | |
using | CompletionData = AsyncCompletionData |
Completion data for AsyncLoopWakeUp. More... | |
using | Result = AsyncResultOf< AsyncLoopWork, CompletionData > |
Callback result for AsyncLoopWakeUp. More... | |
Public Types inherited from SC::AsyncRequest | |
enum class | Type : uint8_t { LoopTimeout , LoopWakeUp , LoopWork , ProcessExit , SocketAccept , SocketConnect , SocketSend , SocketReceive , SocketClose , FileRead , FileWrite , FileClose , FilePoll } |
Type of async request. More... | |
Public Member Functions | |
SC::Result | setThreadPool (ThreadPool &threadPool) |
Sets the ThreadPool that will supply the thread to run the async work on. More... | |
SC::Result | start (AsyncEventLoop &eventLoop) |
Schedule work to be executed on a background thread, notifying the event loop when it's finished. More... | |
Public Member Functions inherited from SC::AsyncRequest | |
void | setDebugName (const char *newDebugName) |
AsyncEventLoop * | getEventLoop () const |
Get the event loop associated with this AsyncRequest. More... | |
void | cacheInternalEventLoop (AsyncEventLoop &loop) |
Caches the event loop associated with this AsyncRequest. More... | |
Result | setThreadPoolAndTask (ThreadPool &pool, AsyncTask &task) |
Sets the thread pool and task to use for this request. More... | |
void | resetThreadPoolAndTask () |
Resets anything previously set with setThreadPoolAndTask. More... | |
AsyncRequest (Type type) | |
Constructs a free async request of given type. More... | |
Result | stop () |
Stops the async operation. More... | |
bool | isFree () const |
Public Attributes | |
Function< SC::Result()> | work |
Function< void(Result &)> | callback |
Called to execute the work in a background threadpool thread. More... | |
Public Attributes inherited from SC::AsyncRequest | |
AsyncRequest * | next = nullptr |
AsyncRequest * | prev = nullptr |
Additional Inherited Members | |
Protected Member Functions inherited from SC::AsyncRequest | |
Result | validateAsync () |
void | queueSubmission (AsyncEventLoop &eventLoop) |
Protected Attributes inherited from SC::AsyncRequest | |
AsyncEventLoop * | eventLoop = nullptr |
AsyncTask * | asyncTask = nullptr |
Executes work in a thread pool and then invokes a callback on the event loop thread.
AsyncLoopWork::work is invoked on one of the thread supplied by the ThreadPool passed during AsyncLoopWork::start. AsyncLoopWork::callback will be called as a completion, on the event loop thread AFTER work callback is finished.
Completion data for AsyncLoopWakeUp.
Callback result for AsyncLoopWakeUp.
SC::Result SC::AsyncLoopWork::setThreadPool | ( | ThreadPool & | threadPool | ) |
Sets the ThreadPool that will supply the thread to run the async work on.
SC::Result SC::AsyncLoopWork::start | ( | AsyncEventLoop & | eventLoop | ) |
Schedule work to be executed on a background thread, notifying the event loop when it's finished.
eventLoop | The AsyncEventLoop where to schedule this work on |
Called to execute the work in a background threadpool thread.