mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Add initiallySignaled parameter to WaitableEvent
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user