| 100 | } |
| 101 | |
| 102 | void Thread::ProcessNext_() { |
| 103 | if (processing_.load()) { |
| 104 | for (const ThreadFunction & func : backQueue_) func(); |
| 105 | backQueue_.clear(); |
| 106 | processing_.store(false); // Signal completion |
| 107 | } |
| 108 | else { |
| 109 | // Sleep a bit to prevent hogging CPU core |
| 110 | std::this_thread::sleep_for(std::chrono::nanoseconds(1)); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | const std::string& Thread::Name() const { |
| 115 | return name_; |