MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / trim

Method trim

thread/stack-allocator.cpp:128–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 return 0;
127 }
128 size_t trim(size_t keep_size) {
129 size_t count = 0;
130 for (int i = 0; in_pool_size > keep_size; i = (i + 1) % N_SLOTS) {
131 if (!slots[i].pool.empty()) {
132 auto ptr = slots[i].pool.back();
133 slots[i].pool.pop_back();
134 in_pool_size -= slots[i].slotsize;
135 count += slots[i].slotsize;
136 __dealloc(ptr, slots[i].slotsize);
137 }
138 }
139 return count;
140 }
141 size_t threshold(size_t x) {
142 trim_threshold = x;
143 return trim_threshold;

Callers 1

Calls 3

emptyMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected