diff --git a/Atomic/Dropbox.h b/Atomic/Dropbox.h index 5967c24..312fddb 100644 --- a/Atomic/Dropbox.h +++ b/Atomic/Dropbox.h @@ -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 >( "" ) ); } }; } diff --git a/Atomic/Mailbox.h b/Atomic/Mailbox.h index 12ac6ba..d420327 100644 --- a/Atomic/Mailbox.h +++ b/Atomic/Mailbox.h @@ -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 );