本文整理汇总了C++中EventQueue::size方法的典型用法代码示例。如果您正苦于以下问题:C++ EventQueue::size方法的具体用法?C++ EventQueue::size怎么用?C++ EventQueue::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventQueue
的用法示例。
在下文中一共展示了EventQueue::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void testSignalExecutor2(void) {
print("*************************************** testSignalExecutor2\r\n");
eq.clear();
TestPwm p1;
TestPwm p2;
p1.period = 2;
p2.period = 3;
complexTestNow = 0;
callbackCounter = 0;
eq.insertTask(&p1.s, 0, (schfunc_t) complexCallback, &p1);
eq.insertTask(&p2.s, 0, (schfunc_t) complexCallback, &p2);
eq.executeAll(complexTestNow);
assertEqualsM("callbackCounter #1", 2, callbackCounter);
assertEquals(2, eq.size());
eq.executeAll(complexTestNow = 2);
assertEqualsM("callbackCounter #2", 3, callbackCounter);
assertEquals(2, eq.size());
eq.executeAll(complexTestNow = 3);
assertEqualsM("callbackCounter #3", 4, callbackCounter);
assertEquals(2, eq.size());
}
示例2: 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?
}
}
示例3: main
int main (int argc, char * const argv[])
{
const char* csv_filename = NULL;
const char* addr = NULL;
const char* port = NULL;
//parsing command line args
int opt;
while ((opt = getopt(argc, argv, "f:")) != -1) {
switch ( opt ) {
case 'f':
csv_filename = optarg;
break;
default:
usage(argv[0]);
return 1;
}
}
if (optind >=(argc-1)) {
usage(argv[0]);
return 1;
}
addr = argv[optind];
port = argv[optind+1];
//end of parsing
registerAllTuples();
setup_signal_handler();
g_txnManager = initTxnManager(); // new
myAddr = UDPAddress(addr, atoi(port) );
UdpSocket u("", atoi(port) );
u.init();
g_udp = &u;
TxnContext ctx = g_txnManager->create();
facts(ctx);
if (csv_filename)
csv_facts(csv_filename, ctx);
//taskQ.commitTables();
ctx.deltaQ.commitTables();
view_maintenance( ctx );
std::cout << "taskQ size=" << taskQ.size() << std::endl;
g_txnManager->commit(ctx);
Event e = Event(Event::NONE, NULL);
callLater(0, boost::bind(demux, e));
u.enableRead();
register_periodics();
iosv.run();
return (0);
}
示例4: GetThreadPriority
QWaitConditionEvent *QWaitConditionPrivate::pre()
{
mtx.lock();
QWaitConditionEvent *wce =
freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst();
wce->priority = GetThreadPriority(GetCurrentThread());
wce->wokenUp = false;
// insert 'wce' into the queue (sorted by priority)
int index = 0;
for (; index < queue.size(); ++index) {
QWaitConditionEvent *current = queue.at(index);
if (current->priority < wce->priority)
break;
}
queue.insert(index, wce);
mtx.unlock();
return wce;
}
示例5: testSignalExecutor
void testSignalExecutor(void) {
testSignalExecutor3();
print("*************************************** testSignalExecutor\r\n");
eq.clear();
assertEquals(EMPTY_QUEUE, eq.getNextEventTime(0));
scheduling_s s1;
scheduling_s s2;
scheduling_s s3;
scheduling_s s4;
eq.insertTask(&s1, 10, callback, NULL);
eq.insertTask(&s4, 10, callback, NULL);
eq.insertTask(&s3, 12, callback, NULL);
eq.insertTask(&s2, 11, callback, NULL);
assertEquals(4, eq.size());
assertEquals(10, eq.getHead()->momentX);
assertEquals(10, eq.getHead()->next->momentX);
assertEquals(11, eq.getHead()->next->next->momentX);
assertEquals(12, eq.getHead()->next->next->next->momentX);
callbackCounter = 0;
eq.executeAll(10);
assertEqualsM("callbackCounter/2", 2, callbackCounter);
callbackCounter = 0;
eq.executeAll(11);
assertEqualsM("callbackCounter/1#1", 1, callbackCounter);
eq.executeAll(100);
assertEquals(0, eq.size());
eq.insertTask(&s1, 12, callback, NULL);
eq.insertTask(&s2, 11, callback, NULL);
eq.insertTask(&s3, 10, callback, NULL);
callbackCounter = 0;
eq.executeAll(10);
assertEqualsM("callbackCounter/1#2", 1, callbackCounter);
callbackCounter = 0;
eq.executeAll(11);
assertEquals(1, callbackCounter);
eq.executeAll(100);
assertEquals(0, eq.size());
callbackCounter = 0;
eq.insertTask(&s1, 10, callback, NULL);
assertEquals(10, eq.getNextEventTime(0));
eq.executeAll(1);
assertEqualsM("callbacks not expected", 0, callbackCounter);
eq.executeAll(11);
assertEquals(1, callbackCounter);
assertEquals(EMPTY_QUEUE, eq.getNextEventTime(0));
eq.insertTask(&s1, 10, callback, NULL);
eq.insertTask(&s2, 13, callback, NULL);
assertEquals(10, eq.getNextEventTime(0));
eq.executeAll(1);
assertEquals(10, eq.getNextEventTime(0));
eq.executeAll(100);
assertEquals(0, eq.size());
callbackCounter = 0;
// both events are scheduled for the same time
eq.insertTask(&s1, 10, callback, NULL);
eq.insertTask(&s2, 10, callback, NULL);
eq.executeAll(11);
assertEquals(2, callbackCounter);
testSignalExecutor2();
}