/* * Copyright (C) 2007-2014 Xagasoft, All rights reserved. * * This file is part of the libbu++ library and is released under the * terms of the license contained in the file LICENSE. */ #ifndef BU_EVENT_H #define BU_EVENT_H #include #include "bu/mutex.h" #include "bu/condition.h" namespace Bu { /** *@ingroup Threading */ class Event { public: Event() { } ~Event() { } void wait() { cBlock.lock(); cBlock.wait(); cBlock.unlock(); } void wait( int nSec, int nUSec ) { cBlock.lock(); cBlock.wait( nSec, nUSec ); cBlock.unlock(); } void unblockOne() { cBlock.lock(); cBlock.signal(); cBlock.unlock(); } void unblockAll() { cBlock.lock(); cBlock.broadcast(); cBlock.unlock(); } private: Condition cBlock; /**< The condition for blocking dequeues. */ }; } #endif