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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_GPU_SYNC_POINT_MANAGER_H_
6 #define CONTENT_COMMON_GPU_SYNC_POINT_MANAGER_H_
7 #pragma once
8
apatrick_chromium 2012/06/05 18:44:15 #include <vector>
piman 2012/06/05 20:09:50 Done.
9 #include "base/callback.h"
10 #include "base/hash_tables.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread_checker.h"
14
15 // This class manages the sync points, which allow cross-channel
16 // synchronization.
17 class SyncPointManager : public base::RefCountedThreadSafe<SyncPointManager>,
18 public base::ThreadChecker {
19 public:
20 SyncPointManager();
21
22 // Generates a sync point, returning its ID. This can me called on any thread.
23 // IDs start at 1.
24 uint32 GenerateSyncPoint();
25
26 // Retires a sync point. This will call all the registered callbacks for this
27 // sync point. This can only be called on the main thread.
28 void RetireSyncPoint(uint32 sync_point);
29
30 // Adds a callback to the sync point. The callback will be called when the
31 // sync point is retired, or immediately (from within that function) if the
32 // sync point was already retired (or not created yet). This can only be
33 // called on the main thread.
34 void AddSyncPointCallback(uint32 sync_point, const base::Closure& callback);
35
36 private:
37 friend class base::RefCountedThreadSafe<SyncPointManager>;
38 typedef std::vector<base::Closure> ClosureList;
39 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.
40
41 ~SyncPointManager();
42
43 // Protects the 2 fields below. Note: callbacks shouldn't be called with this
44 // held.
45 base::Lock lock_;
46 SyncPointMap sync_point_map_;
47 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.
48 };
49
50 #endif // CONTENT_COMMON_GPU_SYNC_POINT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698