rigtorp / MPMCQueue

A bounded multi-producer multi-consumer concurrent queue written in C++11
MIT License
1.18k stars 160 forks source link

non-copyable of MPMCQueue #50

Open OHNOalan opened 3 months ago

OHNOalan commented 3 months ago
  // non-copyable and non-movable
  Queue(const Queue &) = delete;
  Queue &operator=(const Queue &) = delete;

Is there any reason why MPMC is non-copyable and non-movable~ And if I need to use it as a copyable data structure. What should I do~

joadnacer commented 3 months ago

The queue is modified concurrently - in the case that it is modified during your copy, your copy will likely end up in a state that did not exist or that is invalid.

If you want a copyable queue it will surely need to be locking.