コード例 #1
0
ファイル: LaunchDaemon.cpp プロジェクト: garodimb/haiku
/*!	Basic system initialization that must happen before any jobs are launched.
*/
void
LaunchDaemon::_InitSystem()
{
	_AddInitJob(new InitRealTimeClockJob());
	_AddInitJob(new InitSharedMemoryDirectoryJob());
	_AddInitJob(new InitTemporaryDirectoryJob());

	fJobQueue.AddJob(fInitTarget);
}
コード例 #2
0
ファイル: LaunchDaemon.cpp プロジェクト: garodimb/haiku
/*!	Adds the specified \a job to the launch queue
	queue, except those that are triggered by events.

	Unless \c FORCE_NOW is set, the target is only launched if its events,
	if any, have been triggered already.

	Calling this method will trigger a demand event if \c TRIGGER_DEMAND has
	been set.
*/
bool
LaunchDaemon::_LaunchJob(Job* job, uint32 options)
{
	if (job != NULL && (job->IsLaunching() || job->IsRunning()))
		return true;

	if (!_CanLaunchJob(job, options))
		return false;

	// Test if we can launch all requirements
	if (!_CanLaunchJobRequirements(job, options | TRIGGER_DEMAND))
		return false;

	// Actually launch the requirements
	int32 count = job->Requirements().CountStrings();
	for (int32 index = 0; index < count; index++) {
		Job* requirement = FindJob(job->Requirements().StringAt(index));
		if (requirement != NULL) {
			// TODO: For jobs that have their communication channels set up,
			// we would not need to trigger demand at this point
			if (!_LaunchJob(requirement, options | TRIGGER_DEMAND)) {
				// Failed to put a requirement into the launch queue
				return false;
			}
		}
	}

	if (job->Target() != NULL)
		job->Target()->ResolveSourceFiles();
	if (job->Event() != NULL)
		job->Event()->ResetTrigger();

	job->SetLaunching(true);

	status_t status = fJobQueue.AddJob(job);
	if (status != B_OK) {
		debug_printf("Adding job %s to queue failed: %s\n", job->Name(),
			strerror(status));
		return false;
	}

	// Try to launch pending jobs as well
	count = job->Pending().CountStrings();
	for (int32 index = 0; index < count; index++) {
		Job* pending = FindJob(job->Pending().StringAt(index));
		if (pending != NULL && _LaunchJob(pending, 0)) {
			// Remove the job from the pending list once its in the launch
			// queue, so that is not being launched again next time.
			index--;
			count--;
		}
	}

	return true;
}
コード例 #3
0
ファイル: LaunchDaemon.cpp プロジェクト: puckipedia/haiku
/*!	Adds the specified \a job to the launch queue
	queue, except those that are triggered by events.

	Unless \a forceNow is true, the target is only launched if its events,
	if any, have been triggered already.

	Calling this method will trigger a demand event.
*/
void
LaunchDaemon::_LaunchJob(Job* job, bool forceNow)
{
	if (job == NULL || job->IsLaunched() || (!forceNow
		&& (!job->EventHasTriggered() || !job->CheckCondition(*this)
			|| Events::TriggerDemand(job->Event())))) {
		return;
	}

	int32 count = job->Requirements().CountStrings();
	for (int32 index = 0; index < count; index++) {
		Job* requirement = FindJob(job->Requirements().StringAt(index));
		if (requirement != NULL)
			_LaunchJob(requirement);
	}

	if (job->Target() != NULL)
		job->Target()->ResolveSourceFiles();
	if (job->Event() != NULL)
		job->Event()->ResetTrigger();

	fJobQueue.AddJob(job);
}
コード例 #4
0
ファイル: LaunchDaemon.cpp プロジェクト: garodimb/haiku
void
LaunchDaemon::_AddInitJob(BJob* job)
{
	fInitTarget->AddDependency(job);
	fJobQueue.AddJob(job);
}