I will immediately confess that I do very little multithreading, so questions of style and organization in this domain a little fresh to me.
I've written a data structure (in Python, if that matters) which implements a special kind of a queue. I'd like to use this queue to pass messages between threads. Currently, the only logic I have has nothing to do with threads, and simply implements the "special sauce" of organizing messages in this queue.
I like having this queue as a data structure that has nothing to do with threads, just like any other data structure. However, I need to use mutexes, condition variables, etc. to implement the thread safety logic. The question is, where does this logic go?
Do I write a class, say, SpecialQueueConcurrent
derived from SpecialQueue
? Do I write a class that wraps SpecialQueue
instead of deriving from it? Do I provide an option to make it concurrent in the constructor?
How is this usually done?