本文整理汇总了C++中EventQueue::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ EventQueue::empty方法的具体用法?C++ EventQueue::empty怎么用?C++ EventQueue::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventQueue
的用法示例。
在下文中一共展示了EventQueue::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processQueue
void InputService::processQueue(EventQueue& queue)
{
// Send events which are piled on queue so far
size_t numEvents = queue.size(); // TODO: Do we have to limit by numEvents?
while (!queue.empty())
{
EventEntry& e = queue.front();
EventId id = e.eventID;
Ref<InputEvent> evt = e.event;
queue.pop_front();
if (evt && evt->isConsumed())
continue;
EventChannel* channel = e.channel;
if (channel)
{
// If channel specified on post : Send to that channel
channel->send(id, evt);
continue;
}
// When channel not specified: broadcast upward from source channel
if (evt == NULL)
continue; // Can't handle event with no channel specified.
// 1. Broadcast to source channel
Ref<InputSource> source = evt->getSource();
if (source && source->hasChannel())
{
source->channel()->send(id, evt);
if (evt->isConsumed() || !evt->isUplinking())
continue;
}
// 2. Broadcast to device channel
Weak<InputDevice> device = evt->getDevice();
if (device && device->hasChannel())
{
device->channel()->send(id, evt);
if (evt->isConsumed() || !evt->isUplinking())
continue;
}
// 3. Broadcast to user channel
Ref<InputUser> user = evt->getUser();
if (user && user->hasChannel())
{
user->channel()->send(id, evt);
if (evt->isConsumed() || !evt->isUplinking())
continue;
}
// TODO: 4. Broadcast to service channel?
}
}
示例2: Run
/**
* Processes all of the scheduled delegates until there are no more to execute.
* Sleeps when waiting for a scheduled delegate to be ready to invoke to reduce processor usage.
*/
static void Run() { StackTrace trace(__METHOD__, __FILE__, __LINE__);
while (FutureEvents.empty() == false) {
FutureEventHandler event = FutureEvents.top();
FutureEvents.pop();
Sleep(event.Time() - DateTime::Utc());
event();
}
}
示例3: ___updateEventQueue
bool ___updateEventQueue(TimeType t, TimeType & currTime, EventQueue & eventQueue)
{
currTime += t;
if(eventQueue.empty())
return false;
if(currTime >= eventQueue.front().first)
{
eventQueue.front().second();
eventQueue.pop();
currTime = 0.0f;
}
return true;
}
示例4: eventThread
void AbstractDevice::eventThread() {
ADR_GUARD("AbstractDevice::eventThread");
m_thread_exists = true;
while (!m_thread_should_die) {
m_event_mutex.lock();
while (m_events.empty()) {
m_events_available.wait(m_event_mutex, 1);
if (m_thread_should_die) {
break;
}
}
if (m_thread_should_die) {
m_event_mutex.unlock();
break;
}
// Make a local copy of the events so they can be processed without
// leaving the mutex locked.
EventQueue events = m_events;
// Queues don't support clear(). o_o
while (!m_events.empty()) {
m_events.pop();
}
m_event_mutex.unlock();
// Process the events.
while (!events.empty()) {
EventPtr event = events.front();
events.pop();
processEvent(event.get());
}
}
m_thread_exists = false;
}
示例5: demux
void
demux(Event e)
{
if (e.t)
std::cout << "in demux " << e.type << " "<< *e.t << std::endl;
else
std::cout << "in demux (null tuple) " << e.type << std::endl;
assert(e.type==Event::RECV || e.type == Event::NONE);
mainloop(e);
while (!taskQ.empty()){
e = taskQ.dequeue();
std::cout << "in demux loop" << e.type << " "<< *e.t << std::endl;
assert(e.type==Event::RECV || e.type == Event::NONE);
mainloop(e);
}
/*
TxnContext ctx = g_txnManager->create();
demux_handler(e, ctx);
taskQ.commitTables();
view_maintenance( taskQ, ctx );
g_txnManager->commit(ctx);
*/
}