Closed
Description
This has several advantages:
AllocRef
can now be used by concurrent (lock-free) data structures which only have&self
operations. Currently the allocator would need to be wrapped in a mutex even if the allocator is thread-safe.- Allocators can directly expose whether they are thread-safe or not with
Sync
. This bound is inherited by data structures using an allocator: a lock-free queue would only beSync
if its allocator isSync
. We can define a blanket implementation ofAllocRef
for all types implementingGlobalAlloc
. This would allow us to change#[global_allocator]
to requireAllocRef
instead ofGlobalAlloc
. This is not possible ifAllocRef
methods take&mut self
.