forked from Alepha/Alepha
Fix stalls due to lacking custom terminal notifications.
`Dropbox` and `Mailbox` should be roughly the same interface, but with different stall semantics. However, terminal operations don't wait. `finish( custom )` should be a handoff without wait. `Dropbox`'s primary thread-coordination works in terms of an acquire/release semantic whereby `release` doesn't block, so this naturally works. However, `Mailbox` works in terms of the `Interlock` primitive which allows for a terminal-case `checkpoint`. Therefore `finish( custom )` has to call the `checkpoint` api in `Mailbox`
This commit is contained in:
@ -153,10 +153,18 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Dropbox_m
|
||||
sendoff();
|
||||
}
|
||||
|
||||
void
|
||||
finish( auto newNotification )
|
||||
{
|
||||
auto &preparing= drops.producer.acquireBox();
|
||||
preparing.notification= std::make_exception_ptr( std::move( newNotification ) );
|
||||
sendoff();
|
||||
}
|
||||
|
||||
void
|
||||
finish()
|
||||
{
|
||||
notify( build_exception< FinishedCondition >( "" ) );
|
||||
finish( build_exception< FinishedCondition >( "" ) );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -241,6 +241,19 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m
|
||||
checkpoint( lock );
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief This function will pump the mailbox, and deliver a custom notification
|
||||
* event to the other side, without waiting (last step).
|
||||
*/
|
||||
void
|
||||
finish( auto newNotification )
|
||||
{
|
||||
auto notification_ptr= std::make_exception_ptr( std::move( newNotification ) );
|
||||
Alepha::unique_lock lock( access );
|
||||
notification= std::move( notification_ptr );
|
||||
checkpoint( lock );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* @brief This function will pump the mailbox, and deliver a custom notification
|
||||
@ -249,7 +262,7 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m
|
||||
void
|
||||
notify( auto newNotification )
|
||||
{
|
||||
auto notification_ptr= std::make_exception_ptr( std::move( notification ) );
|
||||
auto notification_ptr= std::make_exception_ptr( std::move( newNotification ) );
|
||||
Alepha::unique_lock lock( access );
|
||||
assertion( not finished );
|
||||
notification= std::move( notification_ptr );
|
||||
|
Reference in New Issue
Block a user