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

Unified Diff: base/synchronization/condition_variable.h

Issue 8823012: Prep work for win7-specific condition variable (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years 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
Index: base/synchronization/condition_variable.h
===================================================================
--- base/synchronization/condition_variable.h (revision 113067)
+++ base/synchronization/condition_variable.h (working copy)
@@ -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 @@
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)
« no previous file with comments | « no previous file | base/synchronization/condition_variable_win.cc » ('j') | base/synchronization/condition_variable_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698