cameron314 / concurrentqueue

A fast multi-producer, multi-consumer lock-free concurrent queue for C++11
Other
10k stars 1.69k forks source link

Add a context for allocations #388

Open epoupon opened 5 months ago

epoupon commented 5 months ago

Hello,

Thank you for your work! It would be beneficial to implement a feature that allows the selection of an allocator instance at runtime. For instance, we could introduce an opaque context at the construction of the queue. This context would then be passed to the existing overridable malloc/free method traits. Subsequently, the context could be utilized to determine the appropriate allocator (for my purposes, a pointer would suffice, but the context could be simply defined in the traits class).

Another approach would be to make it stl-compliant, but I am afraid this is more work and will break existing user code.

What do you think?