- simgrid::kernel::activity::CommImplPtr this_synchro(
- new simgrid::kernel::activity::CommImpl(simgrid::kernel::activity::CommImpl::Type::RECEIVE));
- XBT_DEBUG("recv from mbox %p. this_synchro=%p", mbox, this_synchro.get());
-
- simgrid::kernel::activity::CommImplPtr other_comm;
- // communication already done, get it inside the list of completed comms
- if (mbox->is_permanent() && mbox->has_some_done_comm()) {
- XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
- // find a match in the list of already received comms
- other_comm = mbox->find_matching_comm(simgrid::kernel::activity::CommImpl::Type::SEND, match_fun, data,
- this_synchro, /*done*/ true,
- /*remove_matching*/ true);
- // if not found, assume the receiver came first, register it to the mailbox in the classical way
- if (not other_comm) {
- XBT_DEBUG("We have messages in the permanent receive list, but not the one we are looking for, pushing request "
- "into list");
- other_comm = std::move(this_synchro);
- mbox->push(other_comm);
- } else {
- if (other_comm->surf_action_ && other_comm->get_remaining() < 1e-12) {
- XBT_DEBUG("comm %p has been already sent, and is finished, destroy it", other_comm.get());
- other_comm->set_state(simgrid::kernel::activity::State::DONE);
- other_comm->set_mailbox(nullptr);
- }
- }
- } else {
- /* Prepare a comm describing us, so that it gets passed to the user-provided filter of other side */
-
- /* Look for communication activity matching our needs. We also provide a description of
- * ourself so that the other side also gets a chance of choosing if it wants to match with us.
- *
- * If it is not found then push our communication into the rendez-vous point */
- other_comm = mbox->find_matching_comm(simgrid::kernel::activity::CommImpl::Type::SEND, match_fun, data,
- this_synchro, /*done*/ false,
- /*remove_matching*/ true);
-
- if (other_comm == nullptr) {
- XBT_DEBUG("Receive pushed first (%zu comm enqueued so far)", mbox->size());
- other_comm = std::move(this_synchro);
- mbox->push(other_comm);
- } else {
- XBT_DEBUG("Match my %p with the existing %p", this_synchro.get(), other_comm.get());
-
- other_comm->set_state(simgrid::kernel::activity::State::READY);
- }
- receiver->activities_.emplace_back(other_comm);
- }
-
- /* Setup communication synchro */
- other_comm->dst_actor_ = receiver;
- other_comm->dst_data_ = data;
- other_comm->set_dst_buff(dst_buff, dst_buff_size);
-
- if (rate > -1.0 && (other_comm->get_rate() < 0.0 || rate < other_comm->get_rate()))
- other_comm->set_rate(rate);
-
- other_comm->match_fun = match_fun;
- other_comm->copy_data_fun = copy_data_fun;
-
- if (MC_is_active() || MC_record_replay_is_active()) {
- other_comm->set_state(simgrid::kernel::activity::State::RUNNING);
- return other_comm;
- }
- other_comm->start();
- return other_comm;
-}
-
-void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm, double timeout)
-{
- comm->wait_for(simcall->issuer_, timeout);
-}
-
-bool simcall_HANDLER_comm_test(smx_simcall_t, simgrid::kernel::activity::CommImpl* comm)
-{
- return comm->test();
-}
-
-ssize_t simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comms[], size_t count)
-{
- std::vector<simgrid::kernel::activity::CommImpl*> comms_vec(comms, comms + count);
- return simgrid::kernel::activity::CommImpl::test_any(simcall->issuer_, comms_vec);
-}
-
-void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comms[], size_t count,
- double timeout)
-{
- std::vector<simgrid::kernel::activity::CommImpl*> comms_vec(comms, comms + count);
- simgrid::kernel::activity::CommImpl::wait_any_for(simcall->issuer_, comms_vec, timeout);
-}
-
-/******************************************************************************/
-/* SIMIX_comm_copy_data callbacks */
-/******************************************************************************/
-// XBT_ATTRIB_DEPRECATED_v333
-void SIMIX_comm_set_copy_data_callback(void (*callback)(simgrid::kernel::activity::CommImpl*, void*, size_t))
-{
- simgrid::kernel::activity::CommImpl::set_copy_data_callback(callback);