polyfractal/bounded-spsc-queue

Producer and Consumer should opt-out of Sync

reem opened this issue · 3 comments

reem commented

Right now Producer and Consumer are Sync, which allows the user to call try_{push, pop} from multiple threads at once, thus violating the single-consumer-single-producer property and possibly causing memory unsafety.

cc @gankro didn't see anything else obvious

Thanks! I'm assuming opting out is basically just:

impl<T: Send> !Sync for Consumer<T> {}
impl<T: Send> !Sync for Producer<T> {}

?

reem commented

Yes, though you may want to opt out for unbounded T.

Fixed in 70b3508. Thanks!