OLD | NEW |
1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "base/spinlock.h" | 41 #include "base/spinlock.h" |
42 #include "base/thread_annotations.h" | 42 #include "base/thread_annotations.h" |
43 #include "common.h" | 43 #include "common.h" |
44 #include "span.h" | 44 #include "span.h" |
45 | 45 |
46 namespace tcmalloc { | 46 namespace tcmalloc { |
47 | 47 |
48 // Data kept per size-class in central cache. | 48 // Data kept per size-class in central cache. |
49 class CentralFreeList { | 49 class CentralFreeList { |
50 public: | 50 public: |
| 51 // A CentralFreeList may be used before its constructor runs. |
| 52 // So we prevent lock_'s constructor from doing anything to the |
| 53 // lock_ state. |
| 54 CentralFreeList() : lock_(base::LINKER_INITIALIZED) { } |
| 55 |
51 void Init(size_t cl); | 56 void Init(size_t cl); |
52 | 57 |
53 // These methods all do internal locking. | 58 // These methods all do internal locking. |
54 | 59 |
55 // Insert the specified range into the central freelist. N is the number of | 60 // Insert the specified range into the central freelist. N is the number of |
56 // elements in the range. RemoveRange() is the opposite operation. | 61 // elements in the range. RemoveRange() is the opposite operation. |
57 void InsertRange(void *start, void *end, int N); | 62 void InsertRange(void *start, void *end, int N); |
58 | 63 |
59 // Returns the actual number of fetched elements and sets *start and *end. | 64 // Returns the actual number of fetched elements and sets *start and *end. |
60 int RemoveRange(void **start, void **end, int N); | 65 int RemoveRange(void **start, void **end, int N); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 class CentralFreeListPaddedTo<0> : public CentralFreeList { | 191 class CentralFreeListPaddedTo<0> : public CentralFreeList { |
187 }; | 192 }; |
188 | 193 |
189 class CentralFreeListPadded : public CentralFreeListPaddedTo< | 194 class CentralFreeListPadded : public CentralFreeListPaddedTo< |
190 sizeof(CentralFreeList) % 64> { | 195 sizeof(CentralFreeList) % 64> { |
191 }; | 196 }; |
192 | 197 |
193 } // namespace tcmalloc | 198 } // namespace tcmalloc |
194 | 199 |
195 #endif // TCMALLOC_CENTRAL_FREELIST_H_ | 200 #endif // TCMALLOC_CENTRAL_FREELIST_H_ |
OLD | NEW |