| 389 | static IdentityToken_t *s_pAddBlock = NULL; |
| 390 | |
| 391 | bool DBManager::AddToThreadQueue(IDBThreadOperation *op, PrioQueueLevel prio) |
| 392 | { |
| 393 | if (s_pAddBlock && op->GetOwner() == s_pAddBlock) |
| 394 | { |
| 395 | return false; |
| 396 | } |
| 397 | |
| 398 | if (!m_Worker) |
| 399 | { |
| 400 | m_Worker = ke::NewThread("SM Database Worker", [this]() -> void { |
| 401 | Run(); |
| 402 | }); |
| 403 | } |
| 404 | |
| 405 | /* Add to the queue */ |
| 406 | { |
| 407 | std::lock_guard<std::mutex> lock(m_Lock); |
| 408 | Queue<IDBThreadOperation *> &queue = m_OpQueue.GetQueue(prio); |
| 409 | queue.push(op); |
| 410 | m_QueueEvent.notify_one(); |
| 411 | } |
| 412 | |
| 413 | return true; |
| 414 | } |
| 415 | |
| 416 | void DBManager::Run() |
| 417 | { |
no test coverage detected