mpoeter / xenium

A C++ library providing various concurrent data structures and reclamation schemes.
https://mpoeter.github.io/xenium/
MIT License
488 stars 46 forks source link

The question about the interface of data structures #35

Closed moLIart closed 6 months ago

moLIart commented 6 months ago

Hi!

Why no one data structures (or at least _chase_work_stealingdeque) doesn't meet MoveConstructible, MoveAssignable, CopyConstructible and CopyAssignable requirements?

I see that in the tests you use a simple c array to store queues, but why can't we use std::vector or at least std::array?

moLIart commented 6 months ago

Sorry, I figured it out. I'm closing it.

mpoeter commented 6 months ago

Even though you figured it out, let me explain in case someone else stumbles over this issues.

For the same reason std::mutex is neither copyable nor movable. :) It just doesn't make sense to copy or move an object that can potentially be accessed by multiple threads concurrently. If you really do need to move around ownership of such an object, then you need to use some unique_ptr/shared_ptr.