Revert "Eventqueue: Remove unused code"

This reverts commit a7873da89d.
This commit is contained in:
Alexander A. Klimov 2019-05-13 11:29:19 +02:00 committed by Michael Friedrich
parent 23099904c0
commit f601ba51e0
2 changed files with 21 additions and 0 deletions

View File

@ -90,6 +90,25 @@ void EventQueue::SetFilter(std::unique_ptr<Expression> filter)
m_Filter.swap(filter);
}
Dictionary::Ptr EventQueue::WaitForEvent(void *client, double timeout)
{
boost::mutex::scoped_lock lock(m_Mutex);
for (;;) {
auto it = m_Events.find(client);
ASSERT(it != m_Events.end());
if (!it->second.empty()) {
Dictionary::Ptr result = *it->second.begin();
it->second.pop_front();
return result;
}
if (!m_CV.timed_wait(lock, boost::posix_time::milliseconds(long(timeout * 1000))))
return nullptr;
}
}
std::vector<EventQueue::Ptr> EventQueue::GetQueuesForType(const String& type)
{
EventQueueRegistry::ItemMap queues = EventQueueRegistry::GetInstance()->GetItems();

View File

@ -36,6 +36,8 @@ public:
void SetTypes(const std::set<String>& types);
void SetFilter(std::unique_ptr<Expression> filter);
Dictionary::Ptr WaitForEvent(void *client, double timeout = 5);
static std::vector<EventQueue::Ptr> GetQueuesForType(const String& type);
static void UnregisterIfUnused(const String& name, const EventQueue::Ptr& queue);