/** Check if there is a communication going on in a mailbox. */
bool listen();
+ /** Check if there is a communication ready to be consumed from a mailbox. */
+ bool ready();
+
/** Gets the first element in the queue (without dequeuing it), or nullptr if none is there */
smx_activity_t front();
return not this->empty() || (pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty());
}
+bool Mailbox::ready()
+{
+ bool comm_ready = false;
+ if (not pimpl_->comm_queue_.empty()) {
+ comm_ready = pimpl_->comm_queue_.front()->state_ == SIMIX_DONE;
+ }
+ if (!comm_ready && pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty()) {
+ comm_ready = pimpl_->done_comm_queue_.front()->state_ == SIMIX_DONE;
+ }
+ return comm_ready;
+}
+
smx_activity_t Mailbox::front()
{
return pimpl_->comm_queue_.empty() ? nullptr : pimpl_->comm_queue_.front();