本文整理汇总了C++中OsEvent::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ OsEvent::reset方法的具体用法?C++ OsEvent::reset怎么用?C++ OsEvent::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsEvent
的用法示例。
在下文中一共展示了OsEvent::reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testThreadedMultipleFire
void testThreadedMultipleFire()
{
OsEvent event;
MultipleFireThread fireThread(-1, &event);
fireThread.start();
for (int i=0; i<10000; i++)
{
CPPUNIT_ASSERT_EQUAL(OS_SUCCESS, event.wait(500));
CPPUNIT_ASSERT_EQUAL(OS_SUCCESS, event.reset());
}
fireThread.requestShutdown();
}
示例2: testTimedEvent
void testTimedEvent()
{
OsTime eventTimeout(2,0);
OsEvent* pEvent;
pEvent = new OsEvent(12345);
time_t epochTime = time(NULL);
CPPUNIT_ASSERT(pEvent->wait(eventTimeout) != OS_SUCCESS);
pEvent->signal(67890);
CPPUNIT_ASSERT_EQUAL(OS_SUCCESS, pEvent->wait(eventTimeout));
pEvent->reset();
CPPUNIT_ASSERT(pEvent->wait(eventTimeout) != OS_SUCCESS);
epochTime = time(NULL) - epochTime;
// Make sure we waited (approximately) 2 seconds each time.
CPPUNIT_ASSERT(epochTime > 2 && epochTime < 6);
delete pEvent;
}
示例3: main
//.........这里部分代码省略.........
cout << "Exception:" << endl;
cout << " Major Code: " << exc->getMajorCode() << endl;
cout << " Minor Code: " << exc->getMinorCode() << endl;
txt = exc->getText();
cout << " Text: " << txt.data() << endl;
txt = exc->getContext();
cout << " Context: " << txt.data() << endl;
delete exc;
}
#endif
delete pMsgQ1;
/* ============================ OsCallback ================================ */
OsCallback* pCallback;
pCallback = new OsCallback(12345, handleTimerEvent);
pCallback->signal(67890);
delete pCallback;
/* ============================ OsEvent =================================== */
OsTime eventTimeout(2,0);
OsEvent* pEvent;
cout << "Testing OsEvent, please wait..." << endl;
pEvent = new OsEvent(12345);
int epochTime = time(NULL);
assert(pEvent->wait(eventTimeout) != OS_SUCCESS);
pEvent->signal(67890);
assert(pEvent->wait(eventTimeout) == OS_SUCCESS);
pEvent->reset();
assert(pEvent->wait(eventTimeout) != OS_SUCCESS);
epochTime = time(NULL) - epochTime;
// Make sure we waited (approximately) 2 seconds each time.
assert(epochTime > 2 && epochTime < 6);
delete pEvent;
cout << "Done testing OsEvent." << endl;
/* ============================ OsConfigDb ================================ */
OsConfigDb* pConfigDb;
pConfigDb = new OsConfigDb();
delete pConfigDb;
/* ============================ OsTimerTask =============================== */
OsTimerTask* pTimerTask;
pTimerTask = OsTimerTask::getTimerTask();
OsTask::delay(500); // wait 1/2 second
osPrintf("Going to delete the timer task.\n");
delete pTimerTask;
/* ============================ OsTimer =================================== */
pTimerTask = OsTimerTask::getTimerTask();
OsTask::delay(500); // wait 1/2 second
OsCallback* pNotifier;
OsCallback* pNotifier2;
OsTimer* pTimer;
OsTimer* pTimer2;
示例4: main
int main(int argc, char* argv[])
{
parseArgs(argc, argv);
initLogger(argv);
OsEvent taskDone;
Url url(xmlrpcURI);
if (MemCheckDelay)
{
// Delay 45 seconds to allow memcheck start
printf("Wating %d seconds for start of memcheck ...", MemCheckDelay);
OsTask::delay(MemCheckDelay * 1000);
printf("starting\n");
}
// If an input file was specified we start up the number
// of specified threads to execute that input file. If number
// of threads wasn't specified we start up 1 thread.
if (bInputFile)
{
int signaled = 0;
for (int i=0; i<numThreads; i++)
{
ClientTask* pTask = new ClientTask(&taskDone);
pTask->start();
}
// Wait for threads to shut down
while (signaled < numThreads)
{
taskDone.wait();
taskDone.reset();
++signaled;
}
exit(0);
}
switch (Method)
{
case Version: // --version <xmlrpc URI> <dataset>
{
if (optind < argc)
{
fprintf(stderr, "Too many arguments: '%s'\n", argv[optind]);
showHelp(argv);
exit(1);
}
requestVersion(url);
break;
}
case Get: // --get <xmlrpc URI> <dataset> <name> ...
{
UtlSList names;
// copy remaining arguments into the names list
while (optind < argc)
{
names.append(new UtlString(argv[optind++]));
}
requestGet(url, names);
break;
}
case Set: // --set <xmlrpc URI> <dataset> <name> <value> [ <name> <value> ] ...
{
UtlHashMap parameters;
// copy remaining arguments into the names list
while (optind + 1 < argc)
{
UtlString* setName = new UtlString(argv[optind++]);
UtlString* setValue = new UtlString(argv[optind++]);
parameters.insertKeyAndValue(setName, setValue);
}
if (optind < argc)
{
fprintf(stderr, "name '%s' without a value\n", argv[optind]);
showHelp(argv);
exit(1);
}
if (parameters.isEmpty())
{
fprintf(stderr, "must specify at least one name and value\n");
showHelp(argv);
exit(1);
}
else
{
requestSet(url, parameters);
parameters.destroyAll();
}
break;
}
case Delete: // --delete <xmlrpc URI> <dataset> <name> ...
{
//.........这里部分代码省略.........