| Index: gpu/command_buffer/service/sync_point_manager.h
|
| diff --git a/gpu/command_buffer/service/sync_point_manager.h b/gpu/command_buffer/service/sync_point_manager.h
|
| index 8cbf8a838f97c8a2ad57332c25103dfc680a6687..d969fb5cc68fc249a673c013ada8051c95174bbb 100644
|
| --- a/gpu/command_buffer/service/sync_point_manager.h
|
| +++ b/gpu/command_buffer/service/sync_point_manager.h
|
| @@ -10,6 +10,7 @@
|
| #include "base/callback.h"
|
| #include "base/containers/hash_tables.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/synchronization/condition_variable.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "gpu/gpu_export.h"
|
| @@ -18,10 +19,10 @@ namespace gpu {
|
|
|
| // This class manages the sync points, which allow cross-channel
|
| // synchronization.
|
| -class GPU_EXPORT SyncPointManager
|
| - : public base::RefCountedThreadSafe<SyncPointManager> {
|
| +class GPU_EXPORT ThreadedSyncPointManager {
|
| public:
|
| - SyncPointManager();
|
| + ThreadedSyncPointManager();
|
| + ~ThreadedSyncPointManager();
|
|
|
| // Generates a sync point, returning its ID. This can me called on any thread.
|
| // IDs start at a random number. Never return 0.
|
| @@ -39,22 +40,42 @@ class GPU_EXPORT SyncPointManager
|
|
|
| bool IsSyncPointRetired(uint32 sync_point);
|
|
|
| + // Block and wait until this sync point is retired.
|
| + void WaitSyncPoint(uint32 sync_point);
|
| +
|
| private:
|
| - friend class base::RefCountedThreadSafe<SyncPointManager>;
|
| typedef std::vector<base::Closure> ClosureList;
|
| typedef base::hash_map<uint32, ClosureList> SyncPointMap;
|
|
|
| - ~SyncPointManager();
|
| + bool IsSyncPointRetiredLocked(uint32 sync_point);
|
|
|
| - base::ThreadChecker thread_checker_;
|
| -
|
| - // Protects the 2 fields below. Note: callbacks shouldn't be called with this
|
| - // held.
|
| + // Note: callbacks shouldn't be called with this held.
|
| base::Lock lock_;
|
| SyncPointMap sync_point_map_;
|
| uint32 next_sync_point_;
|
| + base::ConditionVariable cond_var_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ThreadedSyncPointManager);
|
| +};
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(SyncPointManager);
|
| +// Does not support retiring and waiting on sync points on different thread.
|
| +// All methods except GenerateSyncPoint must be called on the same thread.
|
| +class GPU_EXPORT SyncPointManager
|
| + : public base::RefCountedThreadSafe<SyncPointManager> {
|
| + public:
|
| + SyncPointManager();
|
| +
|
| + uint32 GenerateSyncPoint();
|
| + void RetireSyncPoint(uint32 sync_point);
|
| + void AddSyncPointCallback(uint32 sync_point, const base::Closure& callback);
|
| + bool IsSyncPointRetired(uint32 sync_point);
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<SyncPointManager>;
|
| + ~SyncPointManager();
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| + ThreadedSyncPointManager threaded_sync_point_manager_;
|
| };
|
|
|
| } // namespace gpu
|
|
|