Lines Matching defs:job

94 	a job, and the external event source.
161 virtual void TeamLaunched(Job* job, status_t status);
204 bool _CanLaunchJob(Job* job, uint32 options,
206 bool _CanLaunchJobRequirements(Job* job,
208 bool _LaunchJob(Job* job, uint32 options = 0);
209 void _StopJob(Job* job, bool force);
211 void _SetCondition(BaseJob* job,
213 void _SetEvent(BaseJob* job,
215 void _SetEnvironment(BaseJob* job,
224 void _GetBaseJobInfo(BaseJob* job, BMessage& info);
233 void _AddInitJob(BJob* job);
461 // as that will be propagated up the chain and prevent this job from being instantiated.
484 LaunchDaemon::TeamLaunched(Job* job, status_t status)
486 fLog.JobLaunched(job, status);
489 fTeams.insert(std::make_pair(job->Team(), job));
573 Job* job = found->second;
574 TRACE("Job %s ended!\n", job->Name());
579 fLog.JobTerminated(job, exitStatus);
580 job->TeamDeleted();
582 if (job->IsService()) {
590 _LaunchJob(job);
599 Job* job = NULL;
605 job = found->second;
610 // Find job by name instead
612 job = FindJob(get_leaf(signature));
613 if (job != NULL) {
619 if (job != NULL) {
623 if (status == B_OK && info.port != job->DefaultPort()) {
624 TRACE("Update default port for %s to %d\n", job->Name(),
626 job->SetDefaultPort(info.port);
692 // Check if its job(s) can be launched now.
699 Job* job = FindJob(name);
700 if (job != NULL) {
701 fLog.EventTriggered(job, event);
702 _LaunchJob(job);
732 Job* job = FindJob(get_leaf(message->GetString("name")));
733 if (job == NULL) {
741 } else if (job->IsService() && !job->IsLaunched()) {
742 if (job->InitCheck() == B_NO_INIT || !job->CheckCondition(*this)) {
743 // The job exists, but cannot be started yet, as its
748 } else if (job->Event() != NULL) {
749 if (!Events::TriggerDemand(job->Event())) {
750 // The job is not triggered by demand; we cannot start it now
753 // The job has already been triggered, don't launch it again
762 // Launch the job if it hasn't been launched already
764 _LaunchJob(job, TRIGGER_DEMAND);
767 status_t result = job->HandleGetLaunchData(message);
769 // Replying is delegated to the job.
802 Job* job = iterator->second;
805 if (job->Target() == baseTarget) {
806 Job* copy = new Job(*job);
883 Job* job = FindJob(name);
884 if (job == NULL) {
897 job->SetEnabled(true);
898 _LaunchJob(job, FORCE_NOW);
915 Job* job = FindJob(name);
916 if (job == NULL) {
929 job->SetEnabled(enable);
930 fLog.JobEnabled(job, enable);
946 Job* job = FindJob(name);
947 if (job == NULL) {
961 fLog.JobStopped(job, force);
962 _StopJob(job, force);
1226 Job* job = iterator->second;
1227 if (job->Target() == target)
1228 info.AddString("job", job->Name());
1268 Job* job = iterator->second;
1269 if (targetName != NULL && (job->Target() == NULL
1270 || job->Target()->Title() != targetName)) {
1273 reply.AddString("job", iterator->first);
1290 Job* job = FindJob(name);
1291 if (job == NULL && !fUserMode) {
1296 BMessage info(uint32(job != NULL ? B_OK : B_NAME_NOT_FOUND));
1297 if (job != NULL) {
1298 _GetBaseJobInfo(job, info);
1300 info.SetInt32("team", job->Team());
1301 info.SetBool("enabled", job->IsEnabled());
1302 info.SetBool("running", job->IsRunning());
1303 info.SetBool("launched", job->IsLaunched());
1304 info.SetBool("service", job->IsService());
1306 if (job->Target() != NULL)
1307 info.SetString("target", job->Target()->Name());
1309 for (int32 i = 0; i < job->Arguments().CountStrings(); i++)
1310 info.AddString("launch", job->Arguments().StringAt(i));
1312 for (int32 i = 0; i < job->Requirements().CountStrings(); i++)
1313 info.AddString("requires", job->Requirements().StringAt(i));
1315 PortMap::const_iterator iterator = job->Ports().begin();
1316 for (; iterator != job->Ports().end(); iterator++)
1338 jobName = filter.GetString("job");
1479 BMessage job;
1481 &job) == B_OK; index++) {
1482 _AddJob(target, true, job);
1485 for (int32 index = 0; message.FindMessage("job", index, &job) == B_OK;
1487 _AddJob(target, false, job);
1513 Job* job = iterator->second;
1516 if (job->Target() == target) {
1518 delete job;
1583 // Invalid job description
1588 Job* job = FindJob(name);
1589 if (job == NULL) {
1590 TRACE(" add job \"%s\"\n", name.String());
1592 job = new (std::nothrow) Job(name);
1593 if (job == NULL)
1596 job->SetTeamListener(this);
1597 job->SetService(service);
1598 job->SetCreateDefaultPort(service);
1599 job->SetTarget(target);
1601 TRACE(" amend job \"%s\"\n", name.String());
1604 job->SetEnabled(!message.GetBool("disabled", !job->IsEnabled()));
1605 fLog.JobEnabled(job, job->IsEnabled());
1609 job->SetCreateDefaultPort(!message.GetBool("legacy", !service));
1611 _SetCondition(job, message);
1612 _SetEvent(job, message);
1613 _SetEnvironment(job, message);
1618 job->AddPort(portMessage);
1622 message.FindStrings("launch", &job->Arguments());
1628 job->AddRequirement(requirement);
1631 job->AddRequirement(fInitTarget->Name());
1633 fJobs.insert(std::make_pair(job->Title(), job));
1645 Job* job = iterator->second;
1648 if (job->Target() != target)
1652 if (job->IsEnabled()) {
1654 if (job->Condition() == NULL || !job->Condition()->IsConstant(*this)
1655 || job->Condition()->Test(*this)) {
1657 status = job->Init(*this, dependencies);
1658 if (status == B_OK && job->Event() != NULL)
1659 status = job->Event()->Register(*this);
1664 fLog.JobInitialized(job);
1668 debug_printf("Init \"%s\" failed: %s\n", job->Name(),
1671 fLog.JobIgnored(job, status);
1675 delete job;
1703 Job* job = iterator->second;
1704 if (job->Target() == target)
1705 _LaunchJob(job);
1720 Job* job = iterator->second;
1721 if (job->Target() == target)
1722 _StopJob(job, force);
1727 /*! Checks whether or not the specified \a job can be launched.
1729 to the \a job.
1732 LaunchDaemon::_CanLaunchJob(Job* job, uint32 options, bool testOnly)
1734 if (job == NULL || !job->CanBeLaunched())
1738 || (job->EventHasTriggered() && job->CheckCondition(*this)
1740 || Events::TriggerDemand(job->Event(), testOnly)));
1744 /*! Checks recursively if the requirements of the specified job can be launched,
1749 LaunchDaemon::_CanLaunchJobRequirements(Job* job, uint32 options)
1751 int32 count = job->Requirements().CountStrings();
1753 Job* requirement = FindJob(job->Requirements().StringAt(index));
1758 requirement->AddPending(job->Name());
1767 /*! Adds the specified \a job to the launch queue
1777 LaunchDaemon::_LaunchJob(Job* job, uint32 options)
1779 if (job != NULL && (job->IsLaunching() || job->IsRunning()))
1782 if (!_CanLaunchJob(job, options))
1786 if (!_CanLaunchJobRequirements(job, options | TRIGGER_DEMAND))
1790 int32 count = job->Requirements().CountStrings();
1792 Job* requirement = FindJob(job->Requirements().StringAt(index));
1803 if (job->Target() != NULL)
1804 job->Target()->ResolveSourceFiles();
1805 if (job->Event() != NULL)
1806 job->Event()->ResetTrigger();
1808 job->SetLaunching(true);
1810 status_t status = fJobQueue.AddJob(job);
1812 debug_printf("Adding job %s to queue failed: %s\n", job->Name(),
1818 count = job->Pending().CountStrings();
1820 Job* pending = FindJob(job->Pending().StringAt(index));
1822 // Remove the job from the pending list once its in the launch
1834 LaunchDaemon::_StopJob(Job* job, bool force)
1836 // TODO: find out which jobs require this job, and don't stop if any,
1838 job->SetEnabled(false);
1840 if (!job->IsRunning())
1845 if (job->GetMessenger(messenger) == B_OK) {
1854 send_signal(-job->Team(), SIGINT);
1856 //send_signal(job->Team(), SIGKILL);
1868 LaunchDaemon::_SetCondition(BaseJob* job, const BMessage& message)
1870 Condition* condition = job->Condition();
1885 job->SetCondition(condition);
1890 LaunchDaemon::_SetEvent(BaseJob* job, const BMessage& message)
1892 Event* event = job->Event();
1908 job->SetEvent(event);
1914 LaunchDaemon::_SetEnvironment(BaseJob* job, const BMessage& message)
1918 job->SetEnvironment(environmentMessage);
1964 LaunchDaemon::_GetBaseJobInfo(BaseJob* job, BMessage& info)
1966 info.SetString("name", job->Name());
1968 if (job->Event() != NULL)
1969 info.SetString("event", job->Event()->ToString());
1971 if (job->Condition() != NULL)
1972 info.SetString("condition", job->Condition()->ToString());
2060 LaunchDaemon::_AddInitJob(BJob* job)
2062 fInitTarget->AddDependency(job);
2063 fJobQueue.AddJob(job);