* Enqueue a configuration object for processing in the pending objects thread. * * @param object The configuration object to be enqueued for processing. * @param bits The dirty bits indicating the type of changes to be processed for the object. */
| 243 | * @param bits The dirty bits indicating the type of changes to be processed for the object. |
| 244 | */ |
| 245 | void IcingaDB::EnqueueConfigObject(const ConfigObject::Ptr& object, uint32_t bits) |
| 246 | { |
| 247 | namespace queue = icingadb::task_queue; |
| 248 | |
| 249 | if (!GetActive() || !m_RconWorker || !m_RconWorker->IsConnected()) { |
| 250 | return; // No need to enqueue anything if we're not connected. |
| 251 | } |
| 252 | |
| 253 | { |
| 254 | std::lock_guard lock(m_PendingItemsMutex); |
| 255 | if (auto [it, inserted] = m_PendingItems.emplace(queue::PendingConfigItem{object, bits}); !inserted) { |
| 256 | m_PendingItems.modify(it, [bits](queue::PendingQueueItem& item) { |
| 257 | auto& configItem = std::get<queue::PendingConfigItem>(item.Item); |
| 258 | if (bits & queue::ConfigDelete) { |
| 259 | configItem.DirtyBits &= ~(queue::ConfigUpdate | queue::FullState); |
| 260 | } else if (bits & queue::ConfigUpdate) { |
| 261 | configItem.DirtyBits &= ~queue::ConfigDelete; |
| 262 | } |
| 263 | configItem.DirtyBits |= bits & queue::DirtyBitsAll; |
| 264 | }); |
| 265 | } |
| 266 | } |
| 267 | m_PendingItemsCV.notify_one(); |
| 268 | } |
| 269 | |
| 270 | void IcingaDB::EnqueueDependencyGroupStateUpdate(const DependencyGroup::Ptr& depGroup) |
| 271 | { |
no test coverage detected