Example #1
0
//---------------------------------------------------------------------------
//	@function:
//		CAutoTaskProxyTest::Unittest_ExecuteWaitFunc
//
//	@doc:
//		Execute *wait* functions with/without cancel
//
//---------------------------------------------------------------------------
void
CAutoTaskProxyTest::Unittest_ExecuteWaitFunc
	(
	CAutoTaskProxy &atp,
	CTask *ptsk,
	BOOL fInvokeCancel,
	EWaitType ewtCur
	)
{
	GPOS_ASSERT(EwtInvalid < ewtCur && EwtSentinel > ewtCur);

	// loop until the task is running or finished
	while (!(ptsk->IsRunning() || ptsk->IsFinished()))
	{
		clib::USleep(1000);
	}

	// cancel the task or not
	if (fInvokeCancel)
	{
		GPOS_ASSERT(ptsk->IsRunning());
		
		// cancel the running task
		atp.Cancel(ptsk);
	}

	GPOS_TRY
	{
		CTask* finishedTask = NULL;

		// invoke the corresponding *wait* function
		switch (ewtCur)
		{
		case EwtWait:
			atp.Wait(ptsk);
			break;
		case EwtWaitAny:
			atp.WaitAny(&finishedTask);
			break;
		case EwtTimedWait:
			atp.TimedWait(ptsk, gpos::ulong_max);
			break;
		case EwtTimedWaitAny:
			atp.TimedWaitAny(&finishedTask, gpos::ulong_max);
			break;
		case EwtDestroy:
			atp.Destroy(ptsk);
			break;
		default:
			GPOS_ASSERT(!"No such functions!");
		}

		// should NOT go here
		GPOS_ASSERT(!"No exceptions were propagated from sub-task!");
	}
	GPOS_CATCH_EX(ex)
	{
		//TODO: Find out what this is doing
		//It breaks the release build on Mac Mini OSX for concourse
		//gcc version Apple LLVM version 7.3.0 (clang-703.0.31)
		//GPOS_MATCH_EX(ex, CException::ExmaSystem, CException::ExmiAbort);
		
		// reset error context
		GPOS_RESET_EX;
	}
	GPOS_CATCH_END;
}
Example #2
0
//---------------------------------------------------------------------------
//	@function:
//		CAutoTaskProxyTest::Unittest_ExecuteWaitFunc
//
//	@doc:
//		Execute *wait* functions with/without cancel
//
//---------------------------------------------------------------------------
void
CAutoTaskProxyTest::Unittest_ExecuteWaitFunc
	(
	CAutoTaskProxy &atp,
	CTask *ptsk,
	BOOL fInvokeCancel,
	EWaitType ewtCur
	)
{
	GPOS_ASSERT(EwtInvalid < ewtCur && EwtSentinel > ewtCur);

	// loop until the task is running or finished
	while (!(ptsk->FRunning() || ptsk->FFinished()))
	{
		clib::USleep(1000);
	}

	// cancel the task or not
	if (fInvokeCancel)
	{
		GPOS_ASSERT(ptsk->FRunning());
		
		// cancel the running task
		atp.Cancel(ptsk);
	}

	GPOS_TRY
	{
		CTask* finishedTask = NULL;

		// invoke the corresponding *wait* function
		switch (ewtCur)
		{
		case EwtWait:
			atp.Wait(ptsk);
			break;
		case EwtWaitAny:
			atp.WaitAny(&finishedTask);
			break;
		case EwtTimedWait:
			atp.EresTimedWait(ptsk, ULONG_MAX);
			break;
		case EwtTimedWaitAny:
			atp.EresTimedWaitAny(&finishedTask, ULONG_MAX);
			break;
		case EwtDestroy:
			atp.Destroy(ptsk);
			break;
		default:
			GPOS_ASSERT(!"No such functions!");
		}

		// should NOT go here
		GPOS_ASSERT(!"No exceptions were propagated from sub-task!");
	}
	GPOS_CATCH_EX(ex)
	{
		GPOS_MATCH_EX(ex, CException::ExmaSystem, CException::ExmiAbort);
		
		// reset error context
		GPOS_RESET_EX;
	}
	GPOS_CATCH_END;
}