From 005b5f8730b8f4b656c49b75e7748063b24c41e6 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 4 Jan 2024 00:37:17 -0500 Subject: [PATCH] Mailbox `wouldBlock` primitive. --- Atomic/Mailbox.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Atomic/Mailbox.h b/Atomic/Mailbox.h index 8cd0684..12ac6ba 100644 --- a/Atomic/Mailbox.h +++ b/Atomic/Mailbox.h @@ -197,6 +197,8 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m return std::move( *pos++ ); } + bool pushWouldBlock() const noexcept { return weight > boxLimit; } + /*! * @brief This function will add mail to the mailbox. * @@ -210,7 +212,7 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m void push( Item item ) { - if( weight > boxLimit ) + if( pushWouldBlock() ) { [[unlikely]]; Alepha::unique_lock lock( access );