| 252 | } |
| 253 | |
| 254 | void Thread::worker_thread() |
| 255 | { |
| 256 | set_thread_affinity(_core_pin); |
| 257 | |
| 258 | while (true) |
| 259 | { |
| 260 | std::unique_lock<std::mutex> lock(_m); |
| 261 | _cv.wait(lock, [&] { return _wait_for_work; }); |
| 262 | _wait_for_work = false; |
| 263 | |
| 264 | _current_exception = nullptr; |
| 265 | |
| 266 | // Exit if the worker thread has not been fed with workloads |
| 267 | if (_workloads == nullptr || _feeder == nullptr) |
| 268 | { |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | // Wake up more peer threads from thread pool if this job has been delegated to the current thread |
| 273 | if (_thread_pool != nullptr) |
| 274 | { |
| 275 | auto thread_it = _thread_pool->begin(); |
| 276 | std::advance(thread_it, std::min(static_cast<unsigned int>(_thread_pool->size()), _wake_beg)); |
| 277 | auto wake_end = std::min(_wake_end, static_cast<unsigned int>(_info.num_threads - 1)); |
| 278 | for (unsigned int t = _wake_beg; t < wake_end; ++t, ++thread_it) |
| 279 | { |
| 280 | thread_it->start(); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED |
| 285 | try |
| 286 | { |
| 287 | #endif /* ARM_COMPUTE_EXCEPTIONS_ENABLED */ |
| 288 | process_workloads(*_workloads, *_feeder, _info); |
| 289 | |
| 290 | #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED |
| 291 | } |
| 292 | catch (...) |
| 293 | { |
| 294 | _current_exception = std::current_exception(); |
| 295 | } |
| 296 | #endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */ |
| 297 | _workloads = nullptr; |
| 298 | _job_complete = true; |
| 299 | lock.unlock(); |
| 300 | _cv.notify_one(); |
| 301 | } |
| 302 | } |
| 303 | } //namespace |
| 304 | |
| 305 | struct CPPScheduler::Impl final |
nothing calls this directly
no test coverage detected