void ThreadTask::SetResult(ThreadTaskResultPtr result) { if (result) { MutexLock lock(result_mutex_); result->task_description_ = task_description_; result_ = result; } else { RootLogError("Null result passed to SetResult"); } }
bool ThreadTask::QueueResult(ThreadTaskResultPtr result) { if (result) { if (task_manager_) { result->task_description_ = task_description_; task_manager_->QueueResult(result); return true; } else { RootLogError("Thread task manager not set, can not queue result"); } } else { RootLogError("Null result passed to QueueResult"); } return false; }
void EventManager::RegisterEvent(event_category_id_t category_id, event_id_t event_id, const std::string& name) { if (!QueryEventCategoryName(category_id).length()) { RootLogError("Trying to register an event for yet unregistered category"); return; } if (event_map_[category_id].find(event_id) != event_map_[category_id].end()) RootLogWarning("Overwriting already registered event with " + name); else RootLogDebug("Registering event " + name); event_map_[category_id][event_id] = name; }
bool EventManager::SendEvent(event_category_id_t category_id, event_id_t event_id, IEventData* data) { if (QThread::currentThreadId() != main_thread_id_) { RootLogError("Tried to send an immediate event (using SendEvent) from a thread " "that is not the main thread. Use SendDelayedEvent() instead."); throw Exception("Tried to send an immediate event (using SendEvent) from a thread" "that is not the main thread. Use SendDelayedEvent() instead."); } // Do not send messages after exit if (framework_->IsExiting()) return false; if (category_id == IllegalEventCategory) { RootLogWarning("Attempted to send event with illegal category"); return false; } // Send event in priority order, until someone returns true for (int i = 0; i < module_subscribers_.size(); ++i) if (SendEvent(module_subscribers_[i], category_id, event_id, data)) return true; // After that send events to components for (int i = 0; i < component_subscribers_.size(); ++i) if (SendEvent(component_subscribers_[i], category_id, event_id, data)) return true; // Then go through QPair<event_category_id_t, event_id_t> group = qMakePair<event_category_id_t, event_id_t>(category_id, event_id); if ( specialEvents_.contains(group) ) { QList<IComponent* >& lst = specialEvents_[group]; for ( int i = 0; i < lst.size(); ++i) { EventSubscriber<IComponent> subs; subs.subscriber_ = lst[i]; if (SendEvent(subs, category_id, event_id, data)) return true; } } return false; }
void ThreadTask::AddRequest(ThreadTaskRequestPtr request) { if (request) { if (!running_) { thread_.join(); // Make sure it's really stopped, not just set the flag to false requests_.push_back(request); running_ = true; finished_ = false; thread_ = boost::thread(boost::ref(*this)); } else { MutexLock lock(request_mutex_); requests_.push_back(request); } request_condition_.notify_one(); } else { RootLogError("Null work request passed to AddRequest"); } }
void Provider::PostInitialize() { tundra_logic_ = framework_->GetModuleManager()->GetModule<TundraLogic::TundraLogicModule>().lock(); if (!tundra_logic_) RootLogError("MumbleVoip::Proviver: Could not get TundraLogicModule"); }