parallel/queue: add nodiscard to push/pop

Users _must_ check the return value otherwise they've no indication
whether anything happened... This is a pretty common mistake because it
looks a lot like a typical push/pop operation.
This commit is contained in:
Danny Robson 2018-03-22 14:57:34 +11:00
parent 4f4b812356
commit 3689b08535

View File

@ -66,7 +66,7 @@ namespace util::parallel {
/// if updating the write pointer fails we bail and return false.
/// else, we will be able to commit the data and return true.
bool
push (const ValueT &val)
push [[nodiscard]] (const ValueT &val)
{
do {
// find our current and next indices, checking there is
@ -119,7 +119,7 @@ namespace util::parallel {
/// importantly: the contents of the provided reference may have been
/// overwritten, but should not be used unless true was returned.
bool
pop (ValueT &out)
pop [[nodiscard]] (ValueT &out)
{
do
{