1.概述
An Event is a synchronization object that allows one thread to signal one or more other threads that a certain event has happened.Usually, one thread signals an event,while one or more other threads waitfor an event to become signalled.
事件是Poco提供的一种线程间通信方式,可用作线程间超时判断或者其他用途。
2.类图
Event类私有继承于EventImpl类。线程锁、条件变量和状态布尔量都是EventImpl的私有成员,系统调用应用于EventImpl的函数成员。
3.接口解析
3.1构造函数
Event::Event(bool autoReset): EventImpl(autoReset)
{
}
EventImpl::EventImpl(bool autoReset): _auto(autoReset), _state(false)
{
#if defined(POCO_VXWORKS)
std::memset(&_mutex, 0, sizeof(_mutex));
#endif
if (pthread_mutex_init(&_mutex, NULL))
throw SystemException("cannot create event (mutex)");
#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
pthread_condattr_t attr;
if (pthread_condattr_init(&attr))
{
pthread_mutex_destroy(&_mutex);
throw<