33 interruptCondition = std::make_shared<std::condition_variable>();
34 interruptConditionVariable = std::make_shared<bool>();
35 *interruptConditionVariable =
false;
37 scheduleObjectsTask->start();
42 scheduleObjectsTask->stop(
false);
43 interruptCondition->notify_all();
44 scheduleObjectsTask->waitForFinished();
52 std::scoped_lock lock(dataMutex);
53 for (
size_t j = 0; j < schedulers.size(); ++j)
55 for (
size_t i = j + 1; i < schedulers.size(); ++i)
57 if (schedulers.at(j).get() == schedulers.at(i).get())
70 schedulers.push_back(scheduler);
71 scheduler->setInteruptConditionVariable(interruptCondition, interruptConditionVariable);
77 std::scoped_lock lock(interruptMutex);
78 *interruptConditionVariable =
true;
79 interruptCondition->notify_all();
84 void ArmarXMultipleObjectsScheduler::schedule()
86 while (!scheduleObjectsTask->isStopped())
90 std::vector<ArmarXObjectSchedulerPtr> tempSchedulers;
92 std::scoped_lock lock(dataMutex);
93 tempSchedulers = schedulers;
95 std::vector<ArmarXObjectSchedulerPtr> schedulersToErase;
99 auto state = sched->getObjectState();
104 case eManagedIceObjectCreated:
106 if (sched->checkDependenciesResolvement())
108 sched->startObject();
112 case eManagedIceObjectInitializing:
114 case eManagedIceObjectInitialized:
115 if (sched->isTerminationRequested())
118 schedulersToErase.push_back(sched);
120 else if (sched->checkDependenciesResolvement())
122 sched->startObject();
125 case eManagedIceObjectStarting:
127 case eManagedIceObjectStarted:
128 if (sched->isTerminationRequested())
130 sched->disconnectObject();
132 schedulersToErase.push_back(sched);
134 else if (!sched->checkDependenciesStatus())
136 sched->disconnectObject();
140 case eManagedIceObjectExiting:
142 case eManagedIceObjectExited:
149 std::scoped_lock lock(dataMutex);
150 std::reverse(schedulersToErase.begin(), schedulersToErase.end());
151 for (
auto sched : schedulersToErase)
156 for (
auto it = schedulers.begin(); it != schedulers.end(); it++)
158 if (sched.get() == it->get())
160 schedulers.erase(it);
166 std::unique_lock lock(interruptMutex);
168 *interruptConditionVariable =
false;
170 while (!*interruptConditionVariable && !scheduleObjectsTask->isStopped())
172 if (interruptCondition->wait_for(lock, std::chrono::milliseconds(2000)) == std::cv_status::timeout)