#pragma once #include "../ds/mpscq.h" #include "../mem/allocconfig.h" #include "../mem/sizeclass.h" #include namespace snmalloc { struct Remote { using alloc_id_t = size_t; union { std::atomic next; Remote* non_atomic_next; }; alloc_id_t allocator_id; void set_target_id(alloc_id_t id) { allocator_id = id; } alloc_id_t target_id() { return allocator_id; } }; struct RemoteAllocator { using alloc_id_t = Remote::alloc_id_t; // Store the message queue on a separate cacheline. It is mutable data that // is read by other threads. alignas(CACHELINE_SIZE) MPSCQ message_queue; alloc_id_t id() { return static_cast( reinterpret_cast(&message_queue)); } }; }