예제 #1
0
 // In any order many at a time:
 bool waitForEventSet(const EventSet& evts, Duration timeout=Duration::seconds(5)) {
     EventSet read_evts;
     for(uint idx = 0; idx < evts.size(); idx++) {
         Event read_evt;
         bool got_event = _events.blockingPop(read_evt, timeout);
         TS_ASSERT(got_event);
         if (!got_event) return false;
         read_evts.insert(read_evt);
     }
     for(EventSet::iterator evt_it = evts.begin(), read_evt_it = read_evts.begin();
         evt_it != evts.end(), read_evt_it != read_evts.end();
         evt_it++, read_evt_it++)
     {
         TS_ASSERT_EQUALS(*evt_it, *read_evt_it);
         if (*evt_it != *read_evt_it) return false;
     }
     return true;
 }
예제 #2
0
	static void UpdateEventMap()
	{
		EventMap map;
		Thread::Mutex::Scoped l(locker_event);
		for(IOMap::const_iterator it = ionew.begin(), ie = ionew.end(); it != ie; ++it)
		{
			PollIO *io = (*it).second;
			iomap[(*it).first] = io;
			if (io->newevent)
				eventset.insert(io);
		}
		ionew.clear();
		for (EventSet::iterator it = eventset.begin(), ie = eventset.end(); it != ie; ++it)
		{
			map.insert( std::make_pair(*it, (*it)->event) );
			(*it)->update   = false;
			(*it)->event    = (*it)->newevent;
			(*it)->newevent = 0;
		}
		eventset.clear();
		wakeup_flag = true;
		std::for_each(map.begin(), map.end(), std::ptr_fun(&LoadEvent));
	}