smol-rs / concurrent-queue

Concurrent multi-producer multi-consumer queue
Apache License 2.0
254 stars 21 forks source link

Make unbounded a const function #67

Closed james7132 closed 4 months ago

james7132 commented 4 months ago

This PR makes ConcurrentQueue::unbounded a const function. It'd be great if bounded could be const as well, but this would likely require static memory allocation support in const functions, which is currently not allowed by the compiler. This would enable https://github.com/smol-rs/async-executor/pull/112 to be directly constructable in a const context (i.e. static/thread_local variable initialization without OnceLock). It might also allow unbounded async_channels to be constructed in a similar context.