From 2cd28fcc0c8073695ab38b9c30e7530750ca8837 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 6 Jan 2016 11:04:25 -0800 Subject: [PATCH] Make FIFO::in() more consistent with other functions. --- firmware/common/fifo.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/common/fifo.hpp b/firmware/common/fifo.hpp index c7441eae..83ee06de 100644 --- a/firmware/common/fifo.hpp +++ b/firmware/common/fifo.hpp @@ -63,13 +63,15 @@ public: } bool in(const T& val) { - const bool is_not_full = !is_full(); - if( is_not_full ) { - _data[_in & mask()] = val; - smp_wmb(); - _in++; + if( is_full() ) { + return false; } - return is_not_full; + + _data[_in & mask()] = val; + smp_wmb(); + _in += 1; + + return true; } size_t in(const T* const buf, size_t len) {