| 115 | |
| 116 | public: |
| 117 | ThreadTasks() : _stop(false) |
| 118 | { |
| 119 | _thread = std::thread([this] { |
| 120 | for (;;) |
| 121 | { |
| 122 | std::function<void()> task; |
| 123 | AsyncTaskCallBack callback; |
| 124 | { |
| 125 | std::unique_lock<std::mutex> lock(this->_queueMutex); |
| 126 | this->_condition.wait(lock, [this] { return this->_stop || !this->_tasks.empty(); }); |
| 127 | if (this->_stop && this->_tasks.empty()) |
| 128 | return; |
| 129 | task = std::move(this->_tasks.front()); |
| 130 | callback = std::move(this->_taskCallBacks.front()); |
| 131 | this->_tasks.pop(); |
| 132 | this->_taskCallBacks.pop(); |
| 133 | } |
| 134 | |
| 135 | task(); |
| 136 | Director::getInstance()->getScheduler()->runOnAxmolThread( |
| 137 | std::bind(callback.callback, callback.callbackParam)); |
| 138 | } |
| 139 | }); |
| 140 | } |
| 141 | ~ThreadTasks() |
| 142 | { |
| 143 | { |
nothing calls this directly
no test coverage detected