NFC: FreeObject: shift readers to take domestication callbacks

If we're going to check next's prev in atomic_read_next, we will need to
domesticate the next pointer first.  We could push the check up, but that opens
boxes, so it's simpler to plumb domestication this far down.  For symmetry, we
also plumb to (non-atomic) read_next.
This commit is contained in:
Nathaniel Wesley Filardo
2021-09-28 12:49:48 +01:00
committed by Nathaniel Wesley Filardo
parent e25db7b832
commit 06e333a3a9
3 changed files with 51 additions and 23 deletions

View File

@@ -102,13 +102,18 @@ namespace snmalloc
/**
* Returns the front message, or null if not possible to return a message.
*/
std::pair<FreeObject::QueuePtr<capptr::bounds::AllocFull>, bool>
std::pair<
FreeObject::HeadPtr<capptr::bounds::AllocFull, capptr::bounds::AllocFull>,
bool>
dequeue(const FreeListKey& key)
{
auto domesticate = [](FreeObject::QueuePtr<capptr::bounds::AllocFull> p)
SNMALLOC_FAST_PATH_LAMBDA { return p; };
invariant();
FreeObject::QueuePtr<capptr::bounds::AllocFull> first = front;
FreeObject::HeadPtr<capptr::bounds::AllocFull, capptr::bounds::AllocFull>
first = domesticate(front);
FreeObject::QueuePtr<capptr::bounds::AllocFull> next =
first->atomic_read_next(key);
first->atomic_read_next(key, domesticate);
if (next != nullptr)
{