OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_RESOURCES_RESOURCE_POOL_H_ | 5 #ifndef CC_RESOURCES_RESOURCE_POOL_H_ |
6 #define CC_RESOURCES_RESOURCE_POOL_H_ | 6 #define CC_RESOURCES_RESOURCE_POOL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 ResourceFormat format); | 29 ResourceFormat format); |
30 scoped_ptr<ScopedResource> TryAcquireResourceWithContentId(uint64 content_id); | 30 scoped_ptr<ScopedResource> TryAcquireResourceWithContentId(uint64 content_id); |
31 void ReleaseResource(scoped_ptr<ScopedResource> resource, | 31 void ReleaseResource(scoped_ptr<ScopedResource> resource, |
32 uint64_t content_id); | 32 uint64_t content_id); |
33 | 33 |
34 void SetResourceUsageLimits(size_t max_memory_usage_bytes, | 34 void SetResourceUsageLimits(size_t max_memory_usage_bytes, |
35 size_t max_unused_memory_usage_bytes, | 35 size_t max_unused_memory_usage_bytes, |
36 size_t max_resource_count); | 36 size_t max_resource_count); |
37 | 37 |
38 void ReduceResourceUsage(); | 38 void ReduceResourceUsage(); |
39 void CheckBusyResources(); | 39 // This might block if |wait_if_needed| is true and one of the currently |
| 40 // busy resources has a read lock fence that needs to be waited upon before |
| 41 // it can be locked for write again. |
| 42 void CheckBusyResources(bool wait_if_needed); |
40 | 43 |
41 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; } | 44 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; } |
42 size_t acquired_memory_usage_bytes() const { | 45 size_t acquired_memory_usage_bytes() const { |
43 return memory_usage_bytes_ - unused_memory_usage_bytes_; | 46 return memory_usage_bytes_ - unused_memory_usage_bytes_; |
44 } | 47 } |
45 size_t total_resource_count() const { return resource_count_; } | 48 size_t total_resource_count() const { return resource_count_; } |
46 size_t acquired_resource_count() const { | 49 size_t acquired_resource_count() const { |
47 return resource_count_ - unused_resources_.size(); | 50 return resource_count_ - unused_resources_.size(); |
48 } | 51 } |
49 size_t busy_resource_count() const { return busy_resources_.size(); } | 52 size_t busy_resource_count() const { return busy_resources_.size(); } |
(...skipping 25 matching lines...) Expand all Loading... |
75 typedef std::deque<PoolResource> ResourceList; | 78 typedef std::deque<PoolResource> ResourceList; |
76 ResourceList unused_resources_; | 79 ResourceList unused_resources_; |
77 ResourceList busy_resources_; | 80 ResourceList busy_resources_; |
78 | 81 |
79 DISALLOW_COPY_AND_ASSIGN(ResourcePool); | 82 DISALLOW_COPY_AND_ASSIGN(ResourcePool); |
80 }; | 83 }; |
81 | 84 |
82 } // namespace cc | 85 } // namespace cc |
83 | 86 |
84 #endif // CC_RESOURCES_RESOURCE_POOL_H_ | 87 #endif // CC_RESOURCES_RESOURCE_POOL_H_ |
OLD | NEW |