Index: gpu/command_buffer/service/sync_point_manager.cc |
diff --git a/gpu/command_buffer/service/sync_point_manager.cc b/gpu/command_buffer/service/sync_point_manager.cc |
index f9206d49776c6eebd9f0e26702a37ee2136e8e87..562fa8ca675c9ea61c4153e5190888caf8eb3fdf 100644 |
--- a/gpu/command_buffer/service/sync_point_manager.cc |
+++ b/gpu/command_buffer/service/sync_point_manager.cc |
@@ -14,25 +14,15 @@ namespace gpu { |
static const int kMaxSyncBase = INT_MAX; |
-// static |
-SyncPointManager* SyncPointManager::Create(bool allow_threaded_calls_and_wait) { |
- return new SyncPointManager(allow_threaded_calls_and_wait); |
-} |
- |
-SyncPointManager::SyncPointManager(bool allow_threaded_calls_and_wait) |
- : allow_threaded_calls_and_wait_(allow_threaded_calls_and_wait), |
+SyncPointManager::SyncPointManager(bool allow_threaded_wait) |
+ : allow_threaded_wait_(allow_threaded_wait), |
// To reduce the risk that a sync point created in a previous GPU process |
// will be in flight in the next GPU process, randomize the starting sync |
// point number. http://crbug.com/373452 |
next_sync_point_(base::RandInt(1, kMaxSyncBase)), |
- retire_cond_var_(&retire_lock_) { |
- if (!allow_threaded_calls_and_wait_) { |
- sequence_checker_.reset(new base::SequenceChecker); |
- } |
-} |
+ retire_cond_var_(&lock_) {} |
-SyncPointManager::~SyncPointManager() { |
-} |
+SyncPointManager::~SyncPointManager() {} |
uint32 SyncPointManager::GenerateSyncPoint() { |
base::AutoLock lock(lock_); |
@@ -52,7 +42,6 @@ uint32 SyncPointManager::GenerateSyncPoint() { |
} |
void SyncPointManager::RetireSyncPoint(uint32 sync_point) { |
- CheckSequencedThread(); |
ClosureList list; |
{ |
base::AutoLock lock(lock_); |
@@ -64,10 +53,8 @@ void SyncPointManager::RetireSyncPoint(uint32 sync_point) { |
} |
list.swap(it->second); |
sync_point_map_.erase(it); |
- } |
- if (allow_threaded_calls_and_wait_) { |
- base::AutoLock lock(retire_lock_); |
- retire_cond_var_.Broadcast(); |
+ if (allow_threaded_wait_) |
+ retire_cond_var_.Broadcast(); |
} |
for (ClosureList::iterator i = list.begin(); i != list.end(); ++i) |
i->Run(); |
@@ -75,7 +62,6 @@ void SyncPointManager::RetireSyncPoint(uint32 sync_point) { |
void SyncPointManager::AddSyncPointCallback(uint32 sync_point, |
const base::Closure& callback) { |
- CheckSequencedThread(); |
{ |
base::AutoLock lock(lock_); |
SyncPointMap::iterator it = sync_point_map_.find(sync_point); |
@@ -88,25 +74,25 @@ void SyncPointManager::AddSyncPointCallback(uint32 sync_point, |
} |
bool SyncPointManager::IsSyncPointRetired(uint32 sync_point) { |
- CheckSequencedThread(); |
- { |
- base::AutoLock lock(lock_); |
- SyncPointMap::iterator it = sync_point_map_.find(sync_point); |
- return it == sync_point_map_.end(); |
- } |
+ base::AutoLock lock(lock_); |
+ return IsSyncPointRetiredLocked(sync_point); |
} |
-void SyncPointManager::ThreadedWaitSyncPoint(uint32 sync_point) { |
- DCHECK(allow_threaded_calls_and_wait_); |
- base::AutoLock lock(retire_lock_); |
- while (!IsSyncPointRetired(sync_point)) { |
+void SyncPointManager::WaitSyncPoint(uint32 sync_point) { |
+ if (!allow_threaded_wait_) { |
+ DCHECK(IsSyncPointRetired(sync_point)); |
+ return; |
+ } |
+ |
+ base::AutoLock lock(lock_); |
+ while (!IsSyncPointRetiredLocked(sync_point)) { |
retire_cond_var_.Wait(); |
} |
} |
-void SyncPointManager::CheckSequencedThread() { |
- DCHECK(allow_threaded_calls_and_wait_ || |
- sequence_checker_->CalledOnValidSequencedThread()); |
+bool SyncPointManager::IsSyncPointRetiredLocked(uint32 sync_point) { |
+ lock_.AssertAcquired(); |
+ return sync_point_map_.find(sync_point) == sync_point_map_.end(); |
} |
} // namespace gpu |