| 1215 | } |
| 1216 | |
| 1217 | bool WBLink::try_schedule_work_item( |
| 1218 | const std::shared_ptr<WorkItem>& work_item) { |
| 1219 | std::unique_lock<std::mutex> lock(m_work_item_queue_mutex, std::try_to_lock); |
| 1220 | if (lock.owns_lock()) { |
| 1221 | if (m_work_item_queue.empty()) { |
| 1222 | m_console->debug("Adding work item {} to queue", work_item->TAG); |
| 1223 | m_work_item_queue.push(work_item); |
| 1224 | return true; |
| 1225 | } |
| 1226 | m_console->debug("Work queue full,cannot add {}", work_item->TAG); |
| 1227 | m_console->warn("Please try again later"); |
| 1228 | return false; |
| 1229 | } |
| 1230 | // Most likely, the lock is hold by the wb_link thread currently performing a |
| 1231 | // previous work item - this is not an error, the user has to try changing |
| 1232 | // param X later. |
| 1233 | m_console->debug("Cannot get lock,cannot add {}", work_item->TAG); |
| 1234 | m_console->warn("Please try again later"); |
| 1235 | return false; |
| 1236 | } |
| 1237 | |
| 1238 | void WBLink::transmit_telemetry_data(TelemetryTxPacket packet) { |
| 1239 | assert(packet.n_injections >= 1); |