I want to write non-blocking code for data types other than POD; those. nontrivially destructible and nontrivially constructive classes.
For example, I need to click on / popping from a multiprocessor queue with multiple consumers without blocking types other than POD.
The boost :: lockfree :: queue implementation, which seems to be the most off-the-shelf real-time implementation that I can find, requires the queue template type to be trivially destructible / constructive.
I could reorganize 10,000 lines of code for my team to separate state from side effects in every class I refer to, and then use the free Boost queue for a new POD state equivalent only to the original type. But before I do this: is there another strategy I can use to write non-blocking code for these non-POD types?
I understand that this prevents side effects from the constructor / destructor that are not blockable / thread safe. What if the data type is basically “POD”, but a non-trivial constructor / destructor is also a “lock”, for example. atomic comparison and exchange for a static member variable? If this data type is considered safe for use in a data structure without blocking, should I roll back my own block-free queue or is there an equivalently stable implementation that I can use instead of the Boost queue?
source
share