Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: base/synchronization/waitable_event.h

Issue 419773002: Take extra lock in base::WaitableEvent::WaitMany. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/synchronization/waitable_event_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/waitable_event.h
diff --git a/base/synchronization/waitable_event.h b/base/synchronization/waitable_event.h
index 26e27791b6a4fe90b39119aee9e97ac74ebf1044..5d193c976ad7b7ef2d15ad19d784fbf8b3801eb1 100644
--- a/base/synchronization/waitable_event.h
+++ b/base/synchronization/waitable_event.h
@@ -72,12 +72,21 @@ class BASE_EXPORT WaitableEvent {
// is not a manual reset event, then this test will cause a reset.
bool IsSignaled();
- // Wait indefinitely for the event to be signaled.
+ // Wait indefinitely for the event to be signaled. Wait's return "happens
+ // after" |Signal| has completed. This means that it's safe for a
+ // WaitableEvent to synchronise its own destruction, like this:
+ //
+ // WaitableEvent *e = new WaitableEvent;
+ // SendToOtherThread(e);
+ // e->Wait();
+ // delete e;
void Wait();
// Wait up until max_time has passed for the event to be signaled. Returns
// true if the event was signaled. If this method returns false, then it
// does not necessarily mean that max_time was exceeded.
+ //
+ // TimedWait can synchronise its own destruction like |Wait|.
bool TimedWait(const TimeDelta& max_time);
#if defined(OS_WIN)
@@ -91,7 +100,8 @@ class BASE_EXPORT WaitableEvent {
// returns: the index of a WaitableEvent which has been signaled.
//
// You MUST NOT delete any of the WaitableEvent objects while this wait is
- // happening.
+ // happening, however WaitMany's return "happens after" the |Signal| call
+ // that caused it has completed, like |Wait|.
static size_t WaitMany(WaitableEvent** waitables, size_t count);
// For asynchronous waiting, see WaitableEventWatcher
« no previous file with comments | « no previous file | base/synchronization/waitable_event_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698