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

Unified Diff: chrome/browser/sync/glue/bookmark_model_worker.h

Issue 488012: Use a ConditionVariable in place of WaitableEvent in BookmarkModelWorker.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: updates from comments 2 Created 11 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
« no previous file with comments | « no previous file | chrome/browser/sync/glue/bookmark_model_worker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/bookmark_model_worker.h
===================================================================
--- chrome/browser/sync/glue/bookmark_model_worker.h (revision 33763)
+++ chrome/browser/sync/glue/bookmark_model_worker.h (working copy)
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_WORKER_H_
#define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_WORKER_H_
+#include "base/condition_variable.h"
#include "base/lock.h"
#include "base/task.h"
#include "base/waitable_event.h"
@@ -30,7 +31,7 @@
pending_work_(NULL),
syncapi_has_shutdown_(false),
bookmark_model_loop_(bookmark_model_loop),
- syncapi_event_(false, false) {
+ syncapi_event_(&lock_) {
}
virtual ~BookmarkModelWorker();
@@ -105,7 +106,6 @@
// We keep a reference to any task we have scheduled so we can gracefully
// force them to run if the syncer is trying to shutdown.
Task* pending_work_;
- Lock pending_work_lock_;
// Set by the SyncCoreThread when Syncapi shutdown has completed and the
// SyncerThread has terminated, so no more work will be scheduled. Read by
@@ -115,12 +115,20 @@
// The BookmarkModel's home-sweet-home MessageLoop.
MessageLoop* const bookmark_model_loop_;
+ // We use a Lock for all data members and a ConditionVariable to synchronize.
+ // We do this instead of using a WaitableEvent and a bool condition in order
+ // to guard against races that could arise due to the fact that the lack of a
+ // barrier permits instructions to be reordered by compiler optimizations.
+ // Possible or not, that route makes for very fragile code due to existence
+ // of theoretical races.
+ Lock lock_;
+
// Used as a barrier at shutdown to ensure the SyncerThread terminates before
// we allow the UI thread to return from Stop(). This gets signalled whenever
// one of two events occur: a new pending_work_ task was scheduled, or the
// SyncerThread has terminated. We only care about (1) when we are in Stop(),
// because we have to manually Run() the task.
- base::WaitableEvent syncapi_event_;
+ ConditionVariable syncapi_event_;
DISALLOW_COPY_AND_ASSIGN(BookmarkModelWorker);
};
« no previous file with comments | « no previous file | chrome/browser/sync/glue/bookmark_model_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698