//--------------------------------------------------------------------------- // @function: // CAutoTaskProxy::Execute // // @doc: // Execute task in thread owning ATP (synchronous execution); // //--------------------------------------------------------------------------- void CAutoTaskProxy::Execute ( CTask *task ) { GPOS_ASSERT(OwnerOf(task) && "Task not owned by this ATP object"); GPOS_ASSERT(CTask::EtsInit == task->m_status && "Task already scheduled"); // mark task as ready to execute task->SetStatus(CTask::EtsDequeued); GPOS_TRY { // get worker of current thread CWorker *worker = CWorker::Self(); GPOS_ASSERT(NULL != worker); // execute task worker->Execute(task); } GPOS_CATCH_EX(ex) { // mark task as erroneous task->SetStatus(CTask::EtsError); if (m_propagate_error) { GPOS_RETHROW(ex); } } GPOS_CATCH_END; // Raise exception if task encounters an exception if (task->HasPendingExceptions()) { if (m_propagate_error) { GPOS_RETHROW(task->GetErrCtxt()->GetException()); } else { task->GetErrCtxt()->Reset(); } } // mark task as reported task->SetReported(); }
//--------------------------------------------------------------------------- // @function: // CAutoTaskProxy::Execute // // @doc: // Execute task in thread owning ATP (synchronous execution); // //--------------------------------------------------------------------------- void CAutoTaskProxy::Execute ( CTask *ptsk ) { GPOS_ASSERT(FOwnerOf(ptsk) && "Task not owned by this ATP object"); GPOS_ASSERT(CTask::EtsInit == ptsk->m_estatus && "Task already scheduled"); // mark task as ready to execute ptsk->SetStatus(CTask::EtsDequeued); GPOS_TRY { // get worker of current thread CWorker *pwrkr = CWorker::PwrkrSelf(); GPOS_ASSERT(NULL != pwrkr); // execute task pwrkr->Execute(ptsk); } GPOS_CATCH_EX(ex) { // mark task as erroneous ptsk->SetStatus(CTask::EtsError); if (m_fPropagateError) { GPOS_RETHROW(ex); } } GPOS_CATCH_END; // Raise exception if task encounters an exception if (ptsk->FPendingExc()) { if (m_fPropagateError) { GPOS_RETHROW(ptsk->Perrctxt()->Exc()); } else { ptsk->Perrctxt()->Reset(); } } // mark task as reported ptsk->SetReported(); }