MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / stopWorkerThreads

Method stopWorkerThreads

highs/parallel/HighsTaskExecutor.h:130–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128 }
129
130 void stopWorkerThreads(bool blocking = false) {
131 // Check if stop has been called already.
132 auto& executorHandle = threadLocalExecutorHandle();
133 if (executorHandle.ptr == nullptr || hasStopped.exchange(true)) return;
134
135 // now inject the null task as termination signal to every worker
136 for (auto& workerDeque : workerDeques) {
137 workerDeque->injectTaskAndNotify(nullptr);
138 }
139
140 // only block if called on main thread, otherwise deadlock may occur
141 if (blocking && executorHandle.isMain) {
142 for (auto& workerThread : workerThreads) {
143 workerThread.join();
144 }
145 } else {
146 for (auto& workerThread : workerThreads) {
147 workerThread.detach();
148 }
149 }
150 }
151
152 static HighsSplitDeque* getThisWorkerDeque() {
153 return threadLocalWorkerDeque();

Callers 2

shutdownMethod · 0.80
disposeMethod · 0.80

Calls 2

injectTaskAndNotifyMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected