Ejemplo n.º 1
0
/* virtual */ OP_STATUS
ES_TimeoutTimerEvent::Signal(ES_Thread *thread, ES_ThreadSignal signal)
{
	switch (signal)
	{
	case ES_SIGNAL_FINISHED:
	case ES_SIGNAL_FAILED:
	case ES_SIGNAL_CANCELLED:
		ES_ThreadListener::Remove();

		if (IsRepeating())
		{
			SetPreviousDelay(GetTotalRequestedDelay());
			return GetTimerManager()->RepeatEvent(this);
		}
		else
			GetTimerManager()->RemoveExpiredEvent(this);
		break;

	default:
		break;
	}

	return OpStatus::OK;
}
Ejemplo n.º 2
0
//
// AEnemySpawnerBase::SpawnEnemies_Implementation
//
void AEnemySpawnerBase::SpawnEnemies_Implementation()
{
	if( IsCleared() )
	{
		return;
	}

	if( bHasTriggered )
	{
		return;
	}
	bHasTriggered = true;

	if( !bShouldWaitForGroupDeath )
	{
		// We're spawning off a timer.
		auto World = GetWorld();
		check( World );
		World->GetTimerManager().SetTimer( GroupSpawnTimer, this, &AEnemySpawnerBase::SpawnNextGroup, SecondsBetweenGroups, true, 0.0f );
	}
	else
	{
		// We're spawning off group deaths.
		SpawnNextGroup();
	}
}
Ejemplo n.º 3
0
//
// AEnemySpawnerBase::SpawnNextGroup
//
void AEnemySpawnerBase::SpawnNextGroup()
{
	auto World = GetWorld();
	check( World );

	++SpawnedGroupsCount;
	if( SpawnedGroupsCount >= Groups && !bShouldWaitForGroupDeath )
	{
		World->GetTimerManager().ClearTimer( GroupSpawnTimer );
	}

	SpawnGroup();
}
Ejemplo n.º 4
0
/* virtual */ OP_BOOLEAN
ES_TimeoutTimerEvent::Expire()
{
	ES_Context *context = runtime->CreateContext(NULL);
	if (!context)
		return OpStatus::ERR_NO_MEMORY;

	ES_TimeoutThread *thread = OP_NEW(ES_TimeoutThread, (context, shared));
	if (!thread)
	{
		ES_Runtime::DeleteContext(context);
		return OpStatus::ERR_NO_MEMORY;
	}

	thread->SetOriginInfo(origin_info);
	thread->SetTimerEvent(this);
#ifdef SCOPE_PROFILER
	thread->SetThreadId(GetScopeThreadId());
#endif // SCOPE_PROFILER

	if (from_plugin_origin)
		thread->SetIsPluginThread();

	OP_BOOLEAN stat = runtime->GetESScheduler()->AddRunnable(thread);
	if (stat == OpBoolean::IS_TRUE)
		/* Thread added to scheduler. Add listener after AddRunnable() since it
		   deletes the thread and all its listeners if scheduler is draining. */
		thread->AddListener(this);
	else if (stat == OpBoolean::IS_FALSE)
		/* Thread not added. Make it repeat here. */
		if (IsRepeating())
		{
			SetNextTimeout();
			SetPreviousDelay(GetTotalRequestedDelay());
			if (OpStatus::IsMemoryError(GetTimerManager()->RepeatEvent(this)))
				return OpBoolean::ERR_NO_MEMORY;
			return OpBoolean::IS_TRUE;
		}

	return stat;
}