forked from Alepha/Alepha
Mailbox wouldBlock primitive.
This commit is contained in:
@ -197,6 +197,8 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m
|
|||||||
return std::move( *pos++ );
|
return std::move( *pos++ );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pushWouldBlock() const noexcept { return weight > boxLimit; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This function will add mail to the mailbox.
|
* @brief This function will add mail to the mailbox.
|
||||||
*
|
*
|
||||||
@ -210,7 +212,7 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m
|
|||||||
void
|
void
|
||||||
push( Item item )
|
push( Item item )
|
||||||
{
|
{
|
||||||
if( weight > boxLimit )
|
if( pushWouldBlock() )
|
||||||
{
|
{
|
||||||
[[unlikely]];
|
[[unlikely]];
|
||||||
Alepha::unique_lock lock( access );
|
Alepha::unique_lock lock( access );
|
||||||
|
|||||||
Reference in New Issue
Block a user