Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::OperationScheduler Class Reference

OperationScheduler object. More...

Inheritance diagram for gem::OperationScheduler:
Collaboration diagram for gem::OperationScheduler:

Public Member Functions

 OperationScheduler (const OperationScheduler &)=delete
 OperationScheduler (OperationScheduler &&)=default
 Default move constructor noexcept is deduced.
OperationScheduler & operator= (const OperationScheduler &)=delete
OperationScheduler & operator= (OperationScheduler &&os)=default
 Default move assignment noexcept is deduced.
int timeout (int msec, OpStrongPtr op, ProgressListener Listener=ProgressListener(), bool selfRef=false) noexcept
 Schedule an operation after given period.
template<typename TOperation>
std::pair< OpStrongPtr, int > timeoutOperation (int msec, TOperation op, ProgressListener Listener=ProgressListener(), bool selfRef=false) noexcept
 Schedule an operation after given period.
int execute (OpStrongPtr op, ProgressListener Listener=ProgressListener(), bool selfRef=false) noexcept
 Schedule the operation for immediate execution on a worker thread.
template<typename TOperation>
std::pair< OpStrongPtr, int > executeOperation (TOperation op, ProgressListener Listener=ProgressListener(), bool selfRef=false) noexcept
 Schedule the operation for a parallel execution.
void cancel (const IScheduledOp *op) noexcept
 Cancel the given operation.

Detailed Description

OperationScheduler object.

Implements share-read / write Api object over IOperationScheduler.

This behaves like a singleton, i.e. all instances are shared behind the same API interface

Member Function Documentation

◆ cancel()

void gem::OperationScheduler::cancel ( const IScheduledOp * op)
inlinenoexcept

Cancel the given operation.

The call will block until the operation is cancelled. If the operation is already in progress, the call will wait for completion before returning If the operation didn't start, the call progress will not receive a 'notifyStart / notifyComplete' notification If no synchronous cancel is needed, the user can cancel by simply resetting the operation handler strong pointer ( unless operation was scheduled with selfRef = true )

Parameters
[in]opScheduled Operation reference

◆ execute()

int gem::OperationScheduler::execute ( OpStrongPtr op,
ProgressListener Listener = ProgressListener(),
bool selfRef = false )
inlinenoexcept

Schedule the operation for immediate execution on a worker thread.

Parameters
[in]opOperation safe reference
[in]Listenerop completion listener ( optional )
[in]selfRef(optional). If set to true the scheduler will lock the OpStrongPtr instance until completion
Returns
Scheduler error code

◆ executeOperation()

template<typename TOperation>
std::pair< OpStrongPtr, int > gem::OperationScheduler::executeOperation ( TOperation op,
ProgressListener Listener = ProgressListener(),
bool selfRef = false )
inlinenoexcept

Schedule the operation for a parallel execution.

Parameters
[in]opOperation handler, may be a lambda, a std::function, etc
[in]Listenerop completion listener ( optional )
[in]selfRef(optional). If set to true the scheduler will lock the OpStrongPtr instance until completion
Returns
pair of <operation handler, error code>

Returned operation handler should be kept by user until completion unless selfRef is set to true, in which case the scheduler will lock the handler

◆ operator=()

OperationScheduler & gem::OperationScheduler::operator= ( OperationScheduler && os)
default

Default move assignment noexcept is deduced.

Parameters
osOperationScheduler to move
Returns
OperationScheduler reference

◆ timeout()

int gem::OperationScheduler::timeout ( int msec,
OpStrongPtr op,
ProgressListener Listener = ProgressListener(),
bool selfRef = false )
inlinenoexcept

Schedule an operation after given period.

Parameters
[in]msecDelay before execution in milliseconds
[in]opOperation safe reference
[in]Listenerop completion listener ( optional )
[in]selfRef(optional). If set to true the scheduler will lock the OpStrongPtr instance until completion
Returns
Scheduler error code

◆ timeoutOperation()

template<typename TOperation>
std::pair< OpStrongPtr, int > gem::OperationScheduler::timeoutOperation ( int msec,
TOperation op,
ProgressListener Listener = ProgressListener(),
bool selfRef = false )
inlinenoexcept

Schedule an operation after given period.

Parameters
[in]msecDelay before execution in milliseconds
[in]opOperation handler, may be a lambda, a std::function, etc
[in]Listenerop completion listener ( optional ).
[in]selfRef(optional). If set to true the scheduler will lock the OpStrongPtr instance until completion
Returns
pair of <operation handler, error code>

Returned operation handler should be kept by user until completion unless selfRef is set to true, in which case the scheduler will lock the handler