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

Unified Diff: gpu/command_buffer/service/sync_point_manager.h

Issue 737943002: Update from https://crrev.com/304715 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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: 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
new file mode 100644
index 0000000000000000000000000000000000000000..8cbf8a838f97c8a2ad57332c25103dfc680a6687
--- /dev/null
+++ b/gpu/command_buffer/service/sync_point_manager.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_
+#define GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted.h"
+#include "base/synchronization/lock.h"
+#include "base/threading/thread_checker.h"
+#include "gpu/gpu_export.h"
+
+namespace gpu {
+
+// This class manages the sync points, which allow cross-channel
+// synchronization.
+class GPU_EXPORT SyncPointManager
+ : public base::RefCountedThreadSafe<SyncPointManager> {
+ public:
+ SyncPointManager();
+
+ // Generates a sync point, returning its ID. This can me called on any thread.
+ // IDs start at a random number. Never return 0.
+ uint32 GenerateSyncPoint();
+
+ // Retires a sync point. This will call all the registered callbacks for this
+ // sync point. This can only be called on the main thread.
+ void RetireSyncPoint(uint32 sync_point);
+
+ // Adds a callback to the sync point. The callback will be called when the
+ // sync point is retired, or immediately (from within that function) if the
+ // sync point was already retired (or not created yet). This can only be
+ // called on the main thread.
+ void AddSyncPointCallback(uint32 sync_point, const base::Closure& callback);
+
+ bool IsSyncPointRetired(uint32 sync_point);
+
+ private:
+ friend class base::RefCountedThreadSafe<SyncPointManager>;
+ typedef std::vector<base::Closure> ClosureList;
+ typedef base::hash_map<uint32, ClosureList> SyncPointMap;
+
+ ~SyncPointManager();
+
+ base::ThreadChecker thread_checker_;
+
+ // Protects the 2 fields below. Note: callbacks shouldn't be called with this
+ // held.
+ base::Lock lock_;
+ SyncPointMap sync_point_map_;
+ uint32 next_sync_point_;
+
+ DISALLOW_COPY_AND_ASSIGN(SyncPointManager);
+};
+
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc ('k') | gpu/command_buffer/service/sync_point_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698