1
0
forked from Alepha/Alepha

Make debugging for mailbox silent.

This commit is contained in:
2023-11-29 19:00:26 -05:00
parent 3b707be882
commit b24b927b67

View File

@ -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() );