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

Unified Diff: content/common/gpu/sync_point_manager.h

Issue 10510013: GPU: Adding sync points for cross-channel synchronization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: protected destructor Created 8 years, 6 months 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: content/common/gpu/sync_point_manager.h
diff --git a/content/common/gpu/sync_point_manager.h b/content/common/gpu/sync_point_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..b30e919001fc6b673959489ab1ec8d6d12eec525
--- /dev/null
+++ b/content/common/gpu/sync_point_manager.h
@@ -0,0 +1,50 @@
+// 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 CONTENT_COMMON_GPU_SYNC_POINT_MANAGER_H_
+#define CONTENT_COMMON_GPU_SYNC_POINT_MANAGER_H_
+#pragma once
+
apatrick_chromium 2012/06/05 18:44:15 #include <vector>
piman 2012/06/05 20:09:50 Done.
+#include "base/callback.h"
+#include "base/hash_tables.h"
+#include "base/memory/ref_counted.h"
+#include "base/synchronization/lock.h"
+#include "base/threading/thread_checker.h"
+
+// This class manages the sync points, which allow cross-channel
+// synchronization.
+class SyncPointManager : public base::RefCountedThreadSafe<SyncPointManager>,
+ public base::ThreadChecker {
+ public:
+ SyncPointManager();
+
+ // Generates a sync point, returning its ID. This can me called on any thread.
+ // IDs start at 1.
+ 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);
+
+ private:
+ friend class base::RefCountedThreadSafe<SyncPointManager>;
+ typedef std::vector<base::Closure> ClosureList;
+ typedef base::hash_map<uint32, std::vector<base::Closure> > SyncPointMap;
apatrick_chromium 2012/06/05 18:44:15 Did you mean to use ClosureList here?
piman 2012/06/05 20:09:50 Yes, thanks! Done.
+
+ ~SyncPointManager();
+
+ // 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_;
apatrick_chromium 2012/06/05 18:44:15 nit: DISALLOW_COPY_AND_ASSIGN
piman 2012/06/05 20:09:50 Done.
+};
+
+#endif // CONTENT_COMMON_GPU_SYNC_POINT_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698