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 | start (AsyncEventLoop &eventLoop, ThreadPool &threadPool) |
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... | |
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 () |
Result | queueSubmission (AsyncEventLoop &eventLoop) |
Result | queueSubmission (AsyncEventLoop &eventLoop, ThreadPool &threadPool, AsyncTask &task) |
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::start | ( | AsyncEventLoop & | eventLoop, |
ThreadPool & | threadPool | ||
) |
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 |
threadPool | The ThreadPool that will supply the background thread |
Called to execute the work in a background threadpool thread.