Add initiallySignaled parameter to WaitableEvent

This commit is contained in:
Vinnie Falco
2013-07-29 12:01:52 -07:00
parent 124afabc7e
commit b5f13537ac
3 changed files with 11 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ void CriticalSection::exit() const noexcept
//==============================================================================
WaitableEvent::WaitableEvent (const bool useManualReset) noexcept
WaitableEvent::WaitableEvent (const bool useManualReset, bool initiallySignaled) noexcept
: triggered (false), manualReset (useManualReset)
{
pthread_cond_init (&condition, 0);
@@ -65,6 +65,9 @@ WaitableEvent::WaitableEvent (const bool useManualReset) noexcept
pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT);
#endif
pthread_mutex_init (&mutex, &atts);
if (initiallySignaled)
signal ();
}
WaitableEvent::~WaitableEvent() noexcept

View File

@@ -80,9 +80,11 @@ void CriticalSection::exit() const noexcept
}
//==============================================================================
WaitableEvent::WaitableEvent (const bool manualReset) noexcept
WaitableEvent::WaitableEvent (const bool manualReset, bool initiallySignaled) noexcept
: internal (CreateEvent (0, manualReset ? TRUE : FALSE, FALSE, 0))
{
if (initiallySignaled)
signal ();
}
WaitableEvent::~WaitableEvent() noexcept

View File

@@ -44,8 +44,11 @@ public:
@param manualReset If this is false, the event will be reset automatically when the wait()
method is called. If manualReset is true, then once the event is signalled,
the only way to reset it will be by calling the reset() method.
@param initiallySignaled If this is true then the event will be signaled when
the constructor returns.
*/
explicit WaitableEvent (bool manualReset = false) noexcept;
explicit WaitableEvent (bool manualReset = false, bool initiallySignaled = false) noexcept;
/** Destructor.