summaryrefslogtreecommitdiffstats
path: root/base/synchronization/condition_variable.h
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-07 19:30:45 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-07 19:30:45 +0000
commit58f66ede2875d1af9757e0c9585ddc2adcc139aa (patch)
tree8d5a9d4c317859c924a7f01860d3b69b39af8829 /base/synchronization/condition_variable.h
parent317c6415bea2bc5d184326188349746911fe5c28 (diff)
downloadchromium_src-58f66ede2875d1af9757e0c9585ddc2adcc139aa.zip
chromium_src-58f66ede2875d1af9757e0c9585ddc2adcc139aa.tar.gz
chromium_src-58f66ede2875d1af9757e0c9585ddc2adcc139aa.tar.bz2
Prep work for win7-specific condition variable
Move windows implementation to pimpl idiom http://c2.com/cgi/wiki?PimplIdiom There should be no behavior change. BUG=none TEST=ConditionVariableTest in base_unittests suffice Review URL: http://codereview.chromium.org/8823012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/synchronization/condition_variable.h')
-rw-r--r--base/synchronization/condition_variable.h77
1 files changed, 3 insertions, 74 deletions
diff --git a/base/synchronization/condition_variable.h b/base/synchronization/condition_variable.h
index 1b3b2ff..60a0b0e 100644
--- a/base/synchronization/condition_variable.h
+++ b/base/synchronization/condition_variable.h
@@ -68,9 +68,7 @@
#include "build/build_config.h"
-#if defined(OS_WIN)
-#include <windows.h>
-#elif defined(OS_POSIX)
+#if defined(OS_POSIX)
#include <pthread.h>
#endif
@@ -80,6 +78,7 @@
namespace base {
+class ConditionVarImpl;
class TimeDelta;
class BASE_EXPORT ConditionVariable {
@@ -102,78 +101,8 @@ class BASE_EXPORT ConditionVariable {
private:
#if defined(OS_WIN)
-
- // Define Event class that is used to form circularly linked lists.
- // The list container is an element with NULL as its handle_ value.
- // The actual list elements have a non-zero handle_ value.
- // All calls to methods MUST be done under protection of a lock so that links
- // can be validated. Without the lock, some links might asynchronously
- // change, and the assertions would fail (as would list change operations).
- class Event {
- public:
- // Default constructor with no arguments creates a list container.
- Event();
- ~Event();
-
- // InitListElement transitions an instance from a container, to an element.
- void InitListElement();
-
- // Methods for use on lists.
- bool IsEmpty() const;
- void PushBack(Event* other);
- Event* PopFront();
- Event* PopBack();
-
- // Methods for use on list elements.
- // Accessor method.
- HANDLE handle() const;
- // Pull an element from a list (if it's in one).
- Event* Extract();
-
- // Method for use on a list element or on a list.
- bool IsSingleton() const;
-
- private:
- // Provide pre/post conditions to validate correct manipulations.
- bool ValidateAsDistinct(Event* other) const;
- bool ValidateAsItem() const;
- bool ValidateAsList() const;
- bool ValidateLinks() const;
-
- HANDLE handle_;
- Event* next_;
- Event* prev_;
- DISALLOW_COPY_AND_ASSIGN(Event);
- };
-
- // Note that RUNNING is an unlikely number to have in RAM by accident.
- // This helps with defensive destructor coding in the face of user error.
- enum RunState { SHUTDOWN = 0, RUNNING = 64213 };
-
- // Internal implementation methods supporting Wait().
- Event* GetEventForWaiting();
- void RecycleEvent(Event* used_event);
-
- RunState run_state_;
-
- // Private critical section for access to member data.
- base::Lock internal_lock_;
-
- // Lock that is acquired before calling Wait().
- base::Lock& user_lock_;
-
- // Events that threads are blocked on.
- Event waiting_list_;
-
- // Free list for old events.
- Event recycling_list_;
- int recycling_list_size_;
-
- // The number of allocated, but not yet deleted events.
- int allocation_counter_;
-
+ ConditionVarImpl* impl_;
#elif defined(OS_POSIX)
-
pthread_cond_t condition_;
pthread_mutex_t* user_mutex_;
#if !defined(NDEBUG)