Closed tmandry closed 4 years ago
Other options include:
take
, and would mean adding a mutex/condvar pair to every slot. This would mean two heap allocations per slot, plus increasing the size of each slot itself by 32 bytes (on linux/x86_64, see https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=5c07e4a6cbf9e3755ff5543a9062d6d9)no_std
, which is an eventual goal...although we could just make the take
method require std.tracing-subscriber
doesn't use it).Another option is that we could consider adding a proper backoff here. We would still be spinning, but could have the thread sleep while spinning rather than just emitting pause
instructions. That would be an obstacle to porting to no_std
, but this code currently doesn't work on no_std
, and we could just feature flag it.
This might be a good compromise between not burning CPU in a tight spin loop and having to allocate a mutex/condvar pair for every slot.
Spinning has different performance/energy characteristics than mutexes/condition vars, and it would be good to document that this is what
take
does.