rigtorp / MPMCQueue

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

Update MPMCQueue.h and add [[nodiscard]] attributes to emty(), idx(), turn(), size() #34

Closed ghost closed 1 year ago

ghost commented 2 years ago

Add [[nodiscard]] attributes

rigtorp commented 2 years ago

Nice, I was going to add this myself. The question is if I should bump the required C++ standard to C++17 which includes [[nodiscard]] or use macros to support C++11.

ghost commented 2 years ago

I was under the impression that unknown attributes are ignored by major compilers. After some research it turns out this is a c++ 17 feature. Macros are better suited then.

rigtorp commented 2 years ago

This approach seems to work well https://github.com/rigtorp/SPSCQueue/pull/31

ghost commented 2 years ago

Done. Also, if not too persnickety, I see no reason to #include a pure C header \<stdlib.h> instead of \<cstdlib>, especially as the other two C headers (cassert, cstddef) were included that way.

rigtorp commented 2 years ago

Done. Also, if not too persnickety, I see no reason to #include a pure C header instead of , especially as the other two C headers (cassert, cstddef) were included that way.

Yes I agree.

Shouldn't try_pop, try_push etc also have NODISCARD?