bool QueueThread::onExecute()
	{
		// Notify the scheduler that this thread has begun its work
		pQueueService.registerWorker(this);

		// Asking for the next job
		while (pQueueService.pWaitingRoom.pop(pJob))
		{
			// Execute the job, via a wrapper for symbol visibility issues
			Yuni::Private::QueueService::JobAccessor<Yuni::Job::IJob>::Execute(*pJob, this);

			// We must release our pointer to the job here to avoid its destruction
			// in `pQueueService.nextJob()` (when `pJob` is re-assigned).
			// This method uses a lock and the destruction of the job may take some time.
			// Obviously, there is absolutely no guarantee that the job will be destroyed
			// at this point but we don't really care
			pJob = nullptr;

			// Cancellation point
			if (YUNI_UNLIKELY(shouldAbort())) // We have to stop as soon as possible, no need for hibernation
				return false;

		} // loop for retrieving jobs to execute

		// Returning true, for hibernation
		return true;
	}
Exemple #2
0
Result DummyTask::run ()
{
	if (duration.inSeconds() < 0.0)
		return Result::ok ();

	Time startTime = Time::getCurrentTime();
    
    setStatusMessage(getName());

	while (elapsed < duration)
	{
		elapsed = Time::getCurrentTime () - startTime;

		if (shouldAbort())
			return Result::ok();

		double progress = 1.0;
		if (duration.inSeconds() > 0)
			progress = elapsed.inSeconds() / duration.inSeconds();
		setProgress(progress);

		Thread::sleep (50);
	}

	return Result::ok ();
}
Exemple #3
0
 virtual ConflictResolutions onWAW(ContentionManager* enemy)
 {
     return shouldAbort(enemy);
 }
Exemple #4
0
 virtual ConflictResolutions onWAR(ContentionManager* e)
 {
     return shouldAbort(e);
 }