Esempio n. 1
0
bool ThreadPool::WorkItem::cancellationPoint()
{
   if( isCancellationRequested() )
   {
      onCancelled();
      return true;
   }
   else
      return false;
}
Esempio n. 2
0
void OsmAnd::Concurrent::Task::run()
{
    // Check if task wants to cancel itself
    if (preExecuteFunctor && _cancellationRequestedByExternal.loadAcquire() == 0)
    {
        bool cancellationRequestedByTask = false;
        preExecuteFunctor(this, cancellationRequestedByTask);
        _cancellationRequestedByTask = cancellationRequestedByTask;
    }

    // If cancellation was not requested by task itself nor by external call
    if (!_cancellationRequestedByTask && _cancellationRequestedByExternal.loadAcquire() == 0)
        executeFunctor(this);

    // Report that execution had finished
    if (postExecuteFunctor)
        postExecuteFunctor(this, isCancellationRequested());
}