| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 // Returns the number of free objects in the transfer cache. | 73 // Returns the number of free objects in the transfer cache. |
| 74 int tc_length(); | 74 int tc_length(); |
| 75 | 75 |
| 76 // Returns the memory overhead (internal fragmentation) attributable | 76 // Returns the memory overhead (internal fragmentation) attributable |
| 77 // to the freelist. This is memory lost when the size of elements | 77 // to the freelist. This is memory lost when the size of elements |
| 78 // in a freelist doesn't exactly divide the page-size (an 8192-byte | 78 // in a freelist doesn't exactly divide the page-size (an 8192-byte |
| 79 // page full of 5-byte objects would have 2 bytes memory overhead). | 79 // page full of 5-byte objects would have 2 bytes memory overhead). |
| 80 size_t OverheadBytes(); | 80 size_t OverheadBytes(); |
| 81 | 81 |
| 82 // Lock/Unlock the internal SpinLock. Used on the pthread_atfork call |
| 83 // to set the lock in a consistent state before the fork. |
| 84 void Lock() { |
| 85 lock_.Lock(); |
| 86 } |
| 87 |
| 88 void Unlock() { |
| 89 lock_.Unlock(); |
| 90 } |
| 91 |
| 82 private: | 92 private: |
| 83 // TransferCache is used to cache transfers of | 93 // TransferCache is used to cache transfers of |
| 84 // sizemap.num_objects_to_move(size_class) back and forth between | 94 // sizemap.num_objects_to_move(size_class) back and forth between |
| 85 // thread caches and the central cache for a given size class. | 95 // thread caches and the central cache for a given size class. |
| 86 struct TCEntry { | 96 struct TCEntry { |
| 87 void *head; // Head of chain of objects. | 97 void *head; // Head of chain of objects. |
| 88 void *tail; // Tail of chain of objects. | 98 void *tail; // Tail of chain of objects. |
| 89 }; | 99 }; |
| 90 | 100 |
| 91 // A central cache freelist can have anywhere from 0 to kMaxNumTransferEntries | 101 // A central cache freelist can have anywhere from 0 to kMaxNumTransferEntries |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 class CentralFreeListPaddedTo<0> : public CentralFreeList { | 201 class CentralFreeListPaddedTo<0> : public CentralFreeList { |
| 192 }; | 202 }; |
| 193 | 203 |
| 194 class CentralFreeListPadded : public CentralFreeListPaddedTo< | 204 class CentralFreeListPadded : public CentralFreeListPaddedTo< |
| 195 sizeof(CentralFreeList) % 64> { | 205 sizeof(CentralFreeList) % 64> { |
| 196 }; | 206 }; |
| 197 | 207 |
| 198 } // namespace tcmalloc | 208 } // namespace tcmalloc |
| 199 | 209 |
| 200 #endif // TCMALLOC_CENTRAL_FREELIST_H_ | 210 #endif // TCMALLOC_CENTRAL_FREELIST_H_ |
| OLD | NEW |