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 | |
56 void Init(size_t cl); | 51 void Init(size_t cl); |
57 | 52 |
58 // These methods all do internal locking. | 53 // These methods all do internal locking. |
59 | 54 |
60 // Insert the specified range into the central freelist. N is the number of | 55 // Insert the specified range into the central freelist. N is the number of |
61 // elements in the range. RemoveRange() is the opposite operation. | 56 // elements in the range. RemoveRange() is the opposite operation. |
62 void InsertRange(void *start, void *end, int N); | 57 void InsertRange(void *start, void *end, int N); |
63 | 58 |
64 // Returns the actual number of fetched elements and sets *start and *end. | 59 // Returns the actual number of fetched elements and sets *start and *end. |
65 int RemoveRange(void **start, void **end, int N); | 60 int RemoveRange(void **start, void **end, int N); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 class CentralFreeListPaddedTo<0> : public CentralFreeList { | 186 class CentralFreeListPaddedTo<0> : public CentralFreeList { |
192 }; | 187 }; |
193 | 188 |
194 class CentralFreeListPadded : public CentralFreeListPaddedTo< | 189 class CentralFreeListPadded : public CentralFreeListPaddedTo< |
195 sizeof(CentralFreeList) % 64> { | 190 sizeof(CentralFreeList) % 64> { |
196 }; | 191 }; |
197 | 192 |
198 } // namespace tcmalloc | 193 } // namespace tcmalloc |
199 | 194 |
200 #endif // TCMALLOC_CENTRAL_FREELIST_H_ | 195 #endif // TCMALLOC_CENTRAL_FREELIST_H_ |
OLD | NEW |