当前位置: 首页>>代码示例>>C++>>正文


C++ EventQueue::getHead方法代码示例

本文整理汇总了C++中EventQueue::getHead方法的典型用法代码示例。如果您正苦于以下问题:C++ EventQueue::getHead方法的具体用法?C++ EventQueue::getHead怎么用?C++ EventQueue::getHead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventQueue的用法示例。


在下文中一共展示了EventQueue::getHead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
}
开发者ID:,项目名称:,代码行数:74,代码来源:


注:本文中的EventQueue::getHead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。