From b24b927b67097505010918b614cb3f5aa9cc220e Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Wed, 29 Nov 2023 19:00:26 -0500 Subject: [PATCH] Make debugging for mailbox silent. --- Atomic/Mailbox.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Atomic/Mailbox.h b/Atomic/Mailbox.h index d4e8775..3090c20 100644 --- a/Atomic/Mailbox.h +++ b/Atomic/Mailbox.h @@ -21,6 +21,13 @@ static_assert( __cplusplus > 2020'99 ); namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m { + namespace C + { + const bool debug= false; + const bool debugInterlock= false or C::debug; + const bool debugPop= false or C::debug; + } + inline namespace exports { template< typename > class Mailbox; @@ -109,7 +116,7 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m void interlock( Lock &lock ) { - error() << "Interlock entered." << std::endl; + if( C::debugInterlock ) error() << "Interlock entered." << std::endl; if( suspended ) awaken( lock ); else { @@ -130,7 +137,10 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m public: explicit inline Mailbox( const size_t lim ) - : boxLimit( lim ) {} + : boxLimit( lim ) + { + assertion( pos == begin( filled ) ); + } /*! * @todo Fix dox... @@ -149,12 +159,13 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m Item pop() { + if( C::debugPop ) error() << "Pop called (" << (void *) this << ")." << std::endl; if( pos == end( filled ) ) [[unlikely]] { - error() << "We might have to hit the sync point." << std::endl; + if( C::debugPop ) error() << "We might have to hit the sync point." << std::endl; if( mustFinish ) raiseFinished(); Alepha::unique_lock lock( access ); - error() << "We have to hit the sync point." << std::endl; + if( C::debugPop ) error() << "We have to hit the sync point." << std::endl; interlock( lock ); if( finished ) { @@ -164,7 +175,7 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m assertion( &*pos != nullptr ); assertion( pos != end( filled ) ); } - else error() << "We did not hit the sync point." << std::endl; + else if( C::debugPop ) error() << "We did not hit the sync point." << std::endl; assertion( pos != end( filled ) ); assertion( not filled.empty() );