in case you need extreme performance, make sure to use capacity which is a power of 2 throughout your system. This will allow to use a more performant ring buffer implementation.