olp-cpp-sdk
1.21.0
|
Encapsulates the execution of an asynchronous task and invocation of a callback in a guaranteed manner. More...
#include <TaskContext.h>
Classes | |
class | Impl |
An implementation helper interface used to declare the Execute , BlockingCancel , and CancelToken functions used by the TaskContext instance. More... | |
class | TaskContextImpl |
Implements the Impl interface. More... | |
Public Member Functions | |
void | Execute () const |
Checks for the cancellation, executes the task, and calls the callback with the result or error. | |
bool | BlockingCancel (std::chrono::milliseconds timeout=std::chrono::seconds(60)) const |
Cancels the operation and waits for the notification. More... | |
client::CancellationToken | CancelToken () const |
Provides a token to cancel the task. More... | |
bool | operator== (const TaskContext &other) const |
Checks whether the values of the TaskContext parameter are the same as the values of the other parameter. More... | |
Static Public Member Functions | |
template<typename Exec , typename Callback > | |
static TaskContext | Create (Exec execute_func, Callback callback, client::CancellationContext context=client::CancellationContext()) |
Creates the TaskContext instance with the provided task and callback. More... | |
Protected Member Functions | |
template<typename Exec , typename Callback , typename ExecResult = typename std::result_of<Exec(client::CancellationContext)>::type> | |
void | SetExecutors (Exec execute_func, Callback callback, client::CancellationContext context) |
Sets the executors for the request. More... | |
Protected Attributes | |
std::shared_ptr< Impl > | impl_ |
The Impl instance. | |
Friends | |
struct | TaskContextHash |
A helper for unordered containers. | |
Encapsulates the execution of an asynchronous task and invocation of a callback in a guaranteed manner.
When the result of the provided task is available, or an error occurs, the callback is invoked.
|
inline |
Cancels the operation and waits for the notification.
timeout | The time (in milliseconds) to wait for the task to finish. |
|
inline |
Provides a token to cancel the task.
CancellationToken
instance.
|
inlinestatic |
Creates the TaskContext
instance with the provided task and callback.
execute_func | The task that should be executed. |
callback | Is invoked once the result of execute_func is available or the task is cancelled. |
context | The CancellationContext instance. |
TaskContext
instance that can be used to run or cancel the task.
|
inline |
Checks whether the values of the TaskContext
parameter are the same as the values of the other
parameter.
other | The TaskContext instance. |
TaskContext
and other
parameters are equal; false otherwise.
|
inlineprotected |
Sets the executors for the request.
execute_func | The task that should be executed. |
callback | Is invoked once the result of execute_func is available or the task is cancelled. |
context | The CancellationContext instance. |