Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // This file contains the definition of the IdAllocator class. | 5 // This file contains the definition of the IdAllocator class. |
| 6 | 6 |
| 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ | 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ |
| 8 #define GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ | 8 #define GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 bool MarkAsUsed(ResourceId id); | 35 bool MarkAsUsed(ResourceId id); |
| 36 | 36 |
| 37 // Frees a resource ID. | 37 // Frees a resource ID. |
| 38 void FreeID(ResourceId id); | 38 void FreeID(ResourceId id); |
| 39 | 39 |
| 40 // Checks whether or not a resource ID is in use. | 40 // Checks whether or not a resource ID is in use. |
| 41 bool InUse(ResourceId id) const; | 41 bool InUse(ResourceId id) const; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // TODO(gman): This would work much better with ranges or a hash table. | 44 // TODO(gman): This would work much better with ranges or a hash table. |
| 45 typedef std::set<ResourceId> ResourceIdSet; | 45 typedef std::set<ResourceId> ResourceIdSet; |
|
greggman
2011/05/26 16:25:29
If were doing this for speed, how about changing t
| |
| 46 | 46 |
| 47 ResourceId FindFirstFree() const; | 47 // The highest ID on the used list. |
| 48 ResourceId LastUsedId() const; | |
| 49 | |
| 50 // Lowest ID that isn't on the used list. This is slow, use as a last resort. | |
| 51 ResourceId FindFirstUnusedId() const; | |
| 48 | 52 |
| 49 ResourceIdSet used_ids_; | 53 ResourceIdSet used_ids_; |
| 54 ResourceIdSet free_ids_; | |
| 50 | 55 |
| 51 DISALLOW_COPY_AND_ASSIGN(IdAllocator); | 56 DISALLOW_COPY_AND_ASSIGN(IdAllocator); |
| 52 }; | 57 }; |
| 53 | 58 |
| 54 } // namespace gpu | 59 } // namespace gpu |
| 55 | 60 |
| 56 #endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ | 61 #endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ |
| OLD | NEW |