194 my_oracle(std::move(oracle)),
195 my_total(my_oracle->total()),
196 my_max_slabs(max_slabs)
198 my_all_slabs.reserve(max_slabs);
199 my_current_cache.reserve(max_slabs);
200 my_future_cache.reserve(max_slabs);
201 my_close_future_subset_cache.reserve(max_slabs);
202 my_far_future_subset_cache.reserve(max_slabs);
204 my_all_subset_details.resize(max_slabs * 2);
205 for (
auto& as : my_all_subset_details) {
206 my_free_subset_details.push_back(&as);
273 std::pair<const Slab_*, Index_>
next(Ifunction_ identify, Cfunction_ create, Pfunction_ populate) {
274 Index_ index = this->
next();
275 auto slab_info = identify(index);
276 if (slab_info.first == my_last_slab_id && my_last_slab) {
277 return std::make_pair(my_last_slab, slab_info.second);
279 my_last_slab_id = slab_info.first;
282 if (my_counter - 1 == my_close_refresh_point) {
283 if (my_all_slabs.empty()) {
285 requisition_subset_close(slab_info.first, slab_info.second);
286 size_t used_slabs = 1;
288 while (++my_close_refresh_point < my_total) {
289 auto future_index = my_oracle->get(my_close_refresh_point);
290 auto future_slab_info = identify(future_index);
291 auto cfcIt = my_close_future_subset_cache.find(future_slab_info.first);
292 if (cfcIt != my_close_future_subset_cache.end()) {
293 OracularSubsettedSlabCache_internals::add_to_details(*(cfcIt->second), future_slab_info.second);
294 }
else if (used_slabs < my_max_slabs) {
295 requisition_subset_close(future_slab_info.first, future_slab_info.second);
298 my_far_slab_id = future_slab_info.first;
299 my_far_slab_offset = future_slab_info.second;
304 my_far_refresh_point = my_close_refresh_point;
306 my_close_refresh_point = my_far_refresh_point;
310 if (my_far_refresh_point < my_total) {
311 requisition_subset_far(my_far_slab_id, my_far_slab_offset);
312 size_t used_slabs = 1;
314 while (++my_far_refresh_point < my_total) {
315 auto future_index = my_oracle->get(my_far_refresh_point);
316 auto future_slab_info = identify(future_index);
317 auto ffcIt = my_far_future_subset_cache.find(future_slab_info.first);
318 if (ffcIt != my_far_future_subset_cache.end()) {
319 OracularSubsettedSlabCache_internals::add_to_details(*(ffcIt->second), future_slab_info.second);
320 }
else if (used_slabs < my_max_slabs) {
321 requisition_subset_far(future_slab_info.first, future_slab_info.second);
324 my_far_slab_id = future_slab_info.first;
325 my_far_slab_offset = future_slab_info.second;
332 for (
auto& cf : my_close_future_subset_cache) {
333 auto cIt = my_current_cache.find(cf.first);
334 if (cIt == my_current_cache.end()) {
335 my_to_reassign.emplace_back(cf.first, cf.second);
337 my_future_cache[cf.first] = cIt->second;
338 my_current_cache.erase(cIt);
343 auto cIt = my_current_cache.begin();
344 for (
auto a : my_to_reassign) {
346 if (cIt == my_current_cache.end()) {
347 my_all_slabs.emplace_back(create());
348 slab_ptr = &(my_all_slabs.back());
350 slab_ptr = cIt->second;
353 my_future_cache[a.first] = slab_ptr;
354 OracularSubsettedSlabCache_internals::finalize_details(*(a.second));
355 my_to_populate.emplace_back(a.first, slab_ptr, a.second);
357 my_to_reassign.clear();
359 populate(my_to_populate);
360 my_to_populate.clear();
370 my_current_cache.clear();
371 my_current_cache.swap(my_future_cache);
375 for (
auto& cfc : my_close_future_subset_cache) {
376 my_free_subset_details.push_back(cfc.second);
378 my_close_future_subset_cache.clear();
379 my_close_future_subset_cache.swap(my_far_future_subset_cache);
383 auto ccIt = my_current_cache.find(slab_info.first);
384 my_last_slab = ccIt->second;
385 return std::make_pair(my_last_slab, slab_info.second);