in src/mem/corealloc.h [480:526]
SNMALLOC_SLOW_PATH decltype(auto)
handle_message_queue_inner(Action action, Args... args)
{
bool need_post = false;
auto local_state = backend_state_ptr();
auto domesticate =
[local_state](freelist::QueuePtr p) SNMALLOC_FAST_PATH_LAMBDA {
return capptr_domesticate<SharedStateHandle>(local_state, p);
};
auto cb = [this, local_state, &need_post](freelist::HeadPtr msg)
SNMALLOC_FAST_PATH_LAMBDA {
#ifdef SNMALLOC_TRACING
std::cout << "Handling remote" << std::endl;
#endif
auto& entry = SharedStateHandle::Pagemap::get_metaentry(
local_state, snmalloc::address_cast(msg));
handle_dealloc_remote(entry, msg.as_void(), need_post);
return true;
};
if constexpr (SharedStateHandle::Options.QueueHeadsAreTame)
{
/*
* The front of the queue has already been validated; just change the
* annotating type.
*/
auto domesticate_first = [](freelist::QueuePtr p)
SNMALLOC_FAST_PATH_LAMBDA {
return freelist::HeadPtr(p.unsafe_ptr());
};
message_queue().dequeue(key_global, domesticate_first, domesticate, cb);
}
else
{
message_queue().dequeue(key_global, domesticate, domesticate, cb);
}
if (need_post)
{
post();
}
return action(args...);
}