Thread safe implementation of circular buffer

Yes.
If you lock all the public methods with the same lock it will be threadsafe.

You could consider using read-write locks, which may have better performance if you have a lot of concurrent readers.

If you don’t have a lot of readers, it will just add overhead, but may be worth checking the option and testing.

Leave a Comment