XBT_PUBLIC_CLASS Actor {
friend Mailbox;
friend simgrid::simix::ActorImpl;
+ friend simgrid::simix::MailboxImpl;
simix::ActorImpl* pimpl_ = nullptr;
/** Wrap a (possibly non-copyable) single-use task into a `std::function` */
XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration);
/************************** Comunication simcalls *****************************/
-/***** Rendez-vous points *****/
-
-XBT_PUBLIC(void) simcall_mbox_set_receiver(smx_mailbox_t mbox , smx_actor_t process);
-
-/***** Communication simcalls *****/
XBT_PUBLIC(void) simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size,
double rate, void *src_buff,
}
void Mailbox::setReceiver(ActorPtr actor) {
- simcall_mbox_set_receiver(pimpl_, actor == nullptr ? nullptr : actor->pimpl_);
+ simix::kernelImmediate([this, actor]() {
+ this->pimpl_->setReceiver(actor);
+ });
}
/** @brief get the receiver (process associated to the mailbox) */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_mailbox, simix, "Mailbox implementation");
-static void SIMIX_mbox_free(void* data);
-static xbt_dict_t mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free);
+static xbt_dict_t mailboxes = xbt_dict_new_homogeneous([](void* data) {
+ delete static_cast<smx_mailbox_t>(data);
+});
void SIMIX_mailbox_exit()
{
xbt_dict_free(&mailboxes);
}
-void SIMIX_mbox_free(void* data)
-{
- XBT_DEBUG("mbox free %p", data);
- smx_mailbox_t mbox = static_cast<smx_mailbox_t>(data);
- delete mbox;
-}
/******************************************************************************/
/* Rendez-Vous Points */
/******************************************************************************/
-/**
- * \brief set the receiver of the rendez vous point to allow eager sends
- * \param mbox The rendez-vous point
- * \param process The receiving process
- */
-void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t process)
-{
- mbox->permanent_receiver = process;
-}
-
namespace simgrid {
namespace simix {
/** @brief Returns the mailbox of that name, or nullptr */
}
return mbox;
}
+/** @brief set the receiver of the mailbox to allow eager sends
+ * \param actor The receiving dude
+ */
+void MailboxImpl::setReceiver(s4u::ActorPtr actor)
+{
+ this->permanent_receiver = actor.get()->getImpl();
+}
/** @brief Pushes a communication activity into a mailbox
* @param activity What to add
*/
static MailboxImpl* byNameOrNull(const char* name);
static MailboxImpl* byNameOrCreate(const char* name);
+ void setReceiver(s4u::ActorPtr actor);
void push(smx_activity_t synchro);
void remove(smx_activity_t activity);
simgrid::s4u::Mailbox piface_; // Our interface
XBT_PRIVATE void SIMIX_mailbox_exit();
-XBT_PRIVATE void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t proc);
-
#endif /* SIMIX_MAILBOXIMPL_H */
return (e_smx_state_t) simcall_BODY_process_sleep(duration);
}
-void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t process)
-{
- simcall_BODY_mbox_set_receiver(mbox, process);
-}
-
/**
* \ingroup simix_comm_management
*/
simgrid::simix::marshal<smx_actor_t>(simcall->result, result);
}
-static inline smx_mailbox_t simcall_mbox_set_receiver__get__mbox(smx_simcall_t simcall) {
- return simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]);
-}
-static inline void simcall_mbox_set_receiver__set__mbox(smx_simcall_t simcall, smx_mailbox_t arg) {
- simgrid::simix::marshal<smx_mailbox_t>(simcall->args[0], arg);
-}
-static inline smx_actor_t simcall_mbox_set_receiver__get__receiver(smx_simcall_t simcall) {
- return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[1]);
-}
-static inline void simcall_mbox_set_receiver__set__receiver(smx_simcall_t simcall, smx_actor_t arg) {
- simgrid::simix::marshal<smx_actor_t>(simcall->args[1], arg);
-}
-
static inline smx_mailbox_t simcall_comm_iprobe__get__mbox(smx_simcall_t simcall) {
return simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]);
}
return simcall<smx_actor_t, smx_actor_t>(SIMCALL_PROCESS_RESTART, process);
}
-inline static void simcall_BODY_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t receiver) {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) SIMIX_mbox_set_receiver(mbox, receiver);
- return simcall<void, smx_mailbox_t, smx_actor_t>(SIMCALL_MBOX_SET_RECEIVER, mbox, receiver);
- }
-
inline static smx_activity_t simcall_BODY_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag, simix_match_func_t match_fun, void* data) {
/* Go to that function to follow the code flow through the simcall barrier */
if (0) simcall_HANDLER_comm_iprobe(&SIMIX_process_self()->simcall, mbox, type, src, tag, match_fun, data);
SIMCALL_PROCESS_ON_EXIT,
SIMCALL_PROCESS_AUTO_RESTART_SET,
SIMCALL_PROCESS_RESTART,
- SIMCALL_MBOX_SET_RECEIVER,
SIMCALL_COMM_IPROBE,
SIMCALL_COMM_SEND,
SIMCALL_COMM_ISEND,
"SIMCALL_PROCESS_ON_EXIT",
"SIMCALL_PROCESS_AUTO_RESTART_SET",
"SIMCALL_PROCESS_RESTART",
- "SIMCALL_MBOX_SET_RECEIVER",
"SIMCALL_COMM_IPROBE",
"SIMCALL_COMM_SEND",
"SIMCALL_COMM_ISEND",
SIMIX_simcall_answer(simcall);
break;
-case SIMCALL_MBOX_SET_RECEIVER:
- SIMIX_mbox_set_receiver(simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]), simgrid::simix::unmarshal<smx_actor_t>(simcall->args[1]));
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_COMM_IPROBE:
simgrid::simix::marshal<smx_activity_t>(simcall->result, simcall_HANDLER_comm_iprobe(simcall, simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1]), simgrid::simix::unmarshal<int>(simcall->args[2]), simgrid::simix::unmarshal<int>(simcall->args[3]), simgrid::simix::unmarshal<simix_match_func_t>(simcall->args[4]), simgrid::simix::unmarshal<void*>(simcall->args[5])));
SIMIX_simcall_answer(simcall);
void process_auto_restart_set(smx_actor_t process, int auto_restart) [[nohandler]];
smx_actor_t process_restart(smx_actor_t process);
-void mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t receiver) [[nohandler]];
-
smx_activity_t comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag, simix_match_func_t match_fun, void* data);
void comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) [[block]];
smx_activity_t comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached);
data->argc = argc;
data->argv = argv;
// set the process attached to the mailbox
- simcall_mbox_set_receiver(data->mailbox_small->getImpl(), proc);
+ data->mailbox_small->setReceiver(simgrid::s4u::Actor::self());
XBT_DEBUG("<%d> New process in the game: %p", index, proc);
}
xbt_assert(smpi_process_data(),