Remove some objects of class "cl" from thread heap and add to central cache
| 211 | |
| 212 | // Remove some objects of class "cl" from thread heap and add to central cache |
| 213 | void ThreadCache::ReleaseToCentralCache(FreeList* src, size_t cl, int N) { |
| 214 | ASSERT(src == &list_[cl]); |
| 215 | ASSERT(N >= 0); |
| 216 | if (static_cast<unsigned int>(N) > src->length()) N = src->length(); |
| 217 | size_t delta_bytes = N * Static::sizemap()->ByteSizeForClass(cl); |
| 218 | |
| 219 | // We return prepackaged chains of the correct size to the central cache. |
| 220 | // TODO: Use the same format internally in the thread caches? |
| 221 | int batch_size = Static::sizemap()->num_objects_to_move(cl); |
| 222 | while (N > batch_size) { |
| 223 | void *tail, *head; |
| 224 | src->PopRange(batch_size, &head, &tail); |
| 225 | Static::central_cache()[cl].InsertRange(head, tail, batch_size); |
| 226 | N -= batch_size; |
| 227 | } |
| 228 | void *tail, *head; |
| 229 | src->PopRange(N, &head, &tail); |
| 230 | Static::central_cache()[cl].InsertRange(head, tail, N); |
| 231 | size_ -= delta_bytes; |
| 232 | } |
| 233 | |
| 234 | // Release idle memory to the central cache |
| 235 | void ThreadCache::Scavenge() { |
nothing calls this directly
no test coverage detected