olp-cpp-sdk  1.22.0
Public Member Functions | List of all members
olp::thread::ExecutionContext Class Referencefinal

Handles the cancellation and final mechanisms. More...

#include <ExecutionContext.h>

Public Member Functions

 ExecutionContext ()
 A default contructor, initializes the ExecutionContextImpl instance.
 
bool Cancelled () const
 Checks whether CancellationContext is cancelled. More...
 
void CancelOperation ()
 
void ExecuteOrCancelled (const ExecuteFuncType &execute_fn, const CancelFuncType &cancel_fn=nullptr)
 
void SetError (client::ApiError error)
 Sets the error that is returned in the Finally method of the execution. More...
 
void SetFailedCallback (FailedCallback callback)
 Sets a callback for SetError. More...
 
const client::CancellationContextGetContext () const
 Gets the CancellationContext object associated with this ExecutionContext instance. More...
 

Detailed Description

Handles the cancellation and final mechanisms.

Member Function Documentation

◆ Cancelled()

bool olp::thread::ExecutionContext::Cancelled ( ) const

Checks whether CancellationContext is cancelled.

Returns
True if CancellationContext is cancelled; false otherwise.

◆ CancelOperation()

void olp::thread::ExecutionContext::CancelOperation ( )

◆ ExecuteOrCancelled()

void olp::thread::ExecutionContext::ExecuteOrCancelled ( const ExecuteFuncType &  execute_fn,
const CancelFuncType &  cancel_fn = nullptr 
)

◆ GetContext()

const client::CancellationContext& olp::thread::ExecutionContext::GetContext ( ) const

Gets the CancellationContext object associated with this ExecutionContext instance.

The caller can use it to cancel the ongoing operation.

Returns
The CancellationContext instance.

◆ SetError()

void olp::thread::ExecutionContext::SetError ( client::ApiError  error)

Sets the error that is returned in the Finally method of the execution.

It immediately finishes the task execution and provides an error via the SetFailedCallback callback of ExecutionContext.

Parameters
errorThe ApiError instance containing the error information.

◆ SetFailedCallback()

void olp::thread::ExecutionContext::SetFailedCallback ( FailedCallback  callback)

Sets a callback for SetError.

Parameters
callbackHandles the finalization of the execution in case of an error.

The documentation for this class was generated from the following file: