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. | |
using | Result = AsyncResultOf<AsyncLoopWork, CompletionData> |
Callback result for AsyncLoopWakeUp. | |
![]() | |
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. | |
![]() | |
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< SC::Result()> | work |
Function< void(Result &)> | callback |
Called to execute the work in a background threadpool thread. | |
![]() | |
AsyncRequest * | next = nullptr |
AsyncRequest * | prev = nullptr |
Friends | |
struct | AsyncEventLoop |
Called after work is done, on the thread calling EventLoop::run() | |
Additional Inherited Members | |
![]() | |
Result | checkState () |
void | queueSubmission (AsyncEventLoop &eventLoop) |
AsyncTaskSequence * | getTask () |
![]() | |
AsyncSequence * | sequence = 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.
|
friend |
Called after work is done, on the thread calling EventLoop::run()
Called to execute the work in a background threadpool thread.