| 169 | bool running = false; |
| 170 | |
| 171 | void start() { |
| 172 | if (running) { |
| 173 | WARN("Engine worker already started"); |
| 174 | return; |
| 175 | } |
| 176 | running = true; |
| 177 | |
| 178 | // Launch thread with same scheduling policy and priority as current thread (ID 0) |
| 179 | int err; |
| 180 | err = pthread_create(&thread, NULL, [](void* p) -> void* { |
| 181 | EngineWorker* that = (EngineWorker*) p; |
| 182 | |
| 183 | // int policy; |
| 184 | // sched_param param; |
| 185 | // if (!pthread_getschedparam(pthread_self(), &policy, ¶m)) { |
| 186 | // DEBUG("EngineWorker %d thread launched with policy %d priority %d", that->id, policy, param.sched_priority); |
| 187 | // } |
| 188 | |
| 189 | that->run(); |
| 190 | return NULL; |
| 191 | }, this); |
| 192 | if (err) { |
| 193 | WARN("EngineWorker %d thread could not be started: %s", id, strerror(err)); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | void requestStop() { |
| 198 | running = false; |
no test coverage detected