diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 14:35:15 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 14:35:15 +0000 |
commit | ffd830813ff2ad974e5b8596e7053cbfc77511f2 (patch) | |
tree | be43c75d0ca05361ed0905e8062fe5f62a583ae8 /base/waitable_event.h | |
parent | 7ce742d8a2434377005763f7b54e4ae844e3e2bd (diff) | |
download | chromium_src-ffd830813ff2ad974e5b8596e7053cbfc77511f2.zip chromium_src-ffd830813ff2ad974e5b8596e7053cbfc77511f2.tar.gz chromium_src-ffd830813ff2ad974e5b8596e7053cbfc77511f2.tar.bz2 |
Provide cross-platform implementation of WaitableEvent for use on Mac and Linux.
I gave the file the suffix _generic since it is implemented entirely in terms of other APIs in base.
This CL also adds a simple unit test for WaitableEvent, and I switched some code in thread.cc over to using WaitableEvent.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/waitable_event.h')
-rw-r--r-- | base/waitable_event.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/base/waitable_event.h b/base/waitable_event.h index 778dabf..be0cd68 100644 --- a/base/waitable_event.h +++ b/base/waitable_event.h @@ -30,12 +30,17 @@ #ifndef BASE_WAITABLE_EVENT_H_ #define BASE_WAITABLE_EVENT_H_ -#include "base/time.h" +#include "base/basictypes.h" #if defined(OS_WIN) typedef void* HANDLE; +#else +#include "base/condition_variable.h" +#include "base/lock.h" #endif +class TimeDelta; + namespace base { // A WaitableEvent can be a useful thread synchronization tool when you want to @@ -71,7 +76,8 @@ class WaitableEvent { // to be woken up. void Signal(); - // Returns true if the event is in the signaled state, else false. + // Returns true if the event is in the signaled state, else false. If this + // is not a manual reset event, then this test will cause a reset. bool IsSignaled(); // Wait indefinitely for the event to be signaled. Returns true if the event @@ -86,7 +92,14 @@ class WaitableEvent { private: #if defined(OS_WIN) HANDLE event_; +#else + Lock lock_; // Needs to be listed first so it will be constructed first. + ConditionVariable cvar_; + bool signaled_; + bool manual_reset_; #endif + + DISALLOW_COPY_AND_ASSIGN(WaitableEvent); }; } // namespace base |