MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / acquire

Method acquire

src/common/image/image_reader.cpp:223–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223bytes ImageMemoryPool::acquire(size_t size) {
224 if (size == 0) {
225 return bytes();
226 }
227
228 const size_t bucket_size = bucket_size_for_image(size);
229
230 std::lock_guard<std::mutex> lock(mutex_);
231
232 auto it = free_lists_.find(bucket_size);
233 if (it != free_lists_.end() && !it->second.empty()) {
234 bytes block = std::move(it->second.back());
235 it->second.pop_back();
236 memset(block.data(), 0, block.size());
237 return block;
238 }
239
240 for (auto candidate = free_lists_.begin(); candidate != free_lists_.end(); ++candidate) {
241 if (candidate->first >= bucket_size && !candidate->second.empty()) {
242 bytes block = std::move(candidate->second.back());
243 candidate->second.pop_back();
244 memset(block.data(), 0, block.size());
245 return block;
246 }
247 }
248
249 return bytes(bucket_size);
250}
251
252void ImageMemoryPool::recycle(bytes&& block) {
253 const size_t size = block.size();

Callers 3

decode_bytesMethod · 0.80
resize_imageMethod · 0.80
reorder_hwc_to_chwMethod · 0.80

Calls 7

bytesClass · 0.85
bucket_size_for_imageFunction · 0.85
endMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected