Starts a wake-up operation, allowing threads to execute callbacks on loop thread. More...
#include <Async.h>
Public Types | |
| using | CompletionData = AsyncCompletionData |
| using | Result = AsyncResultOf<AsyncLoopWakeUp, CompletionData> |
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... | |
Public Member Functions | |
| SC::Result | start (AsyncEventLoop &eventLoop, EventObject &eventObject) |
| Sets async request members and calls AsyncEventLoop::start. | |
| SC::Result | wakeUp (AsyncEventLoop &eventLoop) |
| Wakes up event loop, scheduling AsyncLoopWakeUp::callback on next AsyncEventLoop::run (or its variations) | |
| 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 by SC::AsyncEventLoop::run after SC::AsyncLoopWakeUp::wakeUp. | |
| EventObject * | eventObject = nullptr |
| Optional EventObject to let external threads wait for the callback to end. | |
Public Attributes inherited from SC::AsyncRequest | |
| AsyncRequest * | next = nullptr |
| AsyncRequest * | prev = nullptr |
Friends | |
| struct | AsyncEventLoop |
Additional Inherited Members | |
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 wake-up operation, allowing threads to execute callbacks on loop thread.
SC::AsyncLoopWakeUp::callback will be invoked on the thread running SC::AsyncEventLoop::run (or its variations) after SC::AsyncLoopWakeUp::wakeUp has been called.
An EventObject can be wait-ed to synchronize further actions from the thread invoking the wake up request, ensuring that the callback has finished its execution.
| Result SC::AsyncRequest::start | ( | AsyncEventLoop & | eventLoop | ) |
Shortcut for AsyncEventLoop::start.
| SC::Result SC::AsyncLoopWakeUp::start | ( | AsyncEventLoop & | eventLoop, |
| EventObject & | eventObject ) |
Sets async request members and calls AsyncEventLoop::start.
| SC::Result SC::AsyncLoopWakeUp::wakeUp | ( | AsyncEventLoop & | eventLoop | ) |
Wakes up event loop, scheduling AsyncLoopWakeUp::callback on next AsyncEventLoop::run (or its variations)
Callback called by SC::AsyncEventLoop::run after SC::AsyncLoopWakeUp::wakeUp.
| EventObject* SC::AsyncLoopWakeUp::eventObject = nullptr |
Optional EventObject to let external threads wait for the callback to end.