void
JXApplication::PerformPermanentTasks()
{
	itsMaxSleepTime = kMaxSleepTime;

	if (!itsPermanentTasks->IsEmpty())		// avoid constructing iterator
		{
		JPtrArrayIterator<JXIdleTask> iter(itsPermanentTasks);
		JXIdleTask* task;
		const Time deltaTime = itsCurrentTime - itsLastPermanentTaskTime;
		while (iter.Next(&task))
			{
			Time maxSleepTime = itsMaxSleepTime;
			task->Perform(deltaTime, &maxSleepTime);
			if (maxSleepTime < itsMaxSleepTime)
				{
				itsMaxSleepTime = maxSleepTime;
				}
			}
		}

	// save time for next call

	itsLastPermanentTaskTime = itsCurrentTime;
}
Exemple #2
0
void
JXApplication::PerformIdleTasks()
{
	itsMaxSleepTime = kMaxSleepTime;

	if (!itsIdleTasks->IsEmpty())		// avoid constructing iterator
		{
		JTaskIterator<JXIdleTask> iter(itsIdleTasks);
		JXIdleTask* task;
		const Time deltaTime = itsCurrentTime - itsLastIdleTaskTime;
		while (iter.Next(&task))
			{
			Time maxSleepTime = itsMaxSleepTime;
			task->Perform(deltaTime, &maxSleepTime);
			if (maxSleepTime < itsMaxSleepTime)
				{
				itsMaxSleepTime = maxSleepTime;
				}
			}
		}

	if (!itsHasBlockingWindowFlag)
		{
		// let sockets broadcast

		CheckACEReactor();

		// let processes broadcast -- not necessary to check each time

		itsWaitForChildCounter++;
		if (itsWaitForChildCounter >= kWaitForChildCount)
			{
			JProcess::CheckForFinishedChild(kJFalse);
			itsWaitForChildCounter = 0;
			}
		}

	JXMDIServer* mdiServer = NULL;
	if (JXGetMDIServer(&mdiServer))
		{
		mdiServer->CheckForConnections();
		}

	// save time for next call

	itsLastIdleTaskTime = itsCurrentTime;
}