Selected Documentation for Messaging-Cells Library
Functions | Variables
send_msg.cpp File Reference

Simple send missive example. More...

#include "cell.hh"
+ Include dependency graph for send_msg.cpp:

Functions

void recv_cell_handler (missive *msg)
 This function will handle messages for a cell when it has zero in cell::handler_idx and kernel::all_handlers has been set to the_handlers with kernel::set_handlers.
 

Variables

missive_handler_t the_handlers []
 This will be kernel::all_handlers when kernel::set_handlers gets called.
 

Detailed Description

Simple send missive example.

/*************************************************************
This file is part of messaging-cells.
messaging-cells is free software: you can redistribute it and/or modify
it under the terms of the version 3 of the GNU General Public
License as published by the Free Software Foundation.
messaging-cells is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with messaging-cells. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------
Copyright (C) 2017-2018. QUIROGA BELTRAN, Jose Luis.
Id (cedula): 79523732 de Bogota - Colombia.
See https://messaging-cells.github.io/
messaging-cells is free software thanks to The Glory of Our Lord
Yashua Melej Hamashiaj.
Our Resurrected and Living, both in Body and Spirit,
Prince of Peace.
------------------------------------------------------------*/
#include "cell.hh"
void
PTD_CODE(
PTD_CK(mc_addr_is_local(msg->dst));
MC_MARK_USED(koid);
MC_MARK_USED(konn);
PTD_LOG("recv_cell_handler. workeru_id=%lx workeru_nn=%d src=%p dst=%p \n",
koid, konn, msg->get_source(), msg->dst);
PTD_PRT("recv_cell_handler. workeru_id=%lx workeru_nn=%d src=%p dst=%p \n",
koid, konn, msg->get_source(), msg->dst);
)
mck_slog2("GOT MISSIVE\n");
mck_get_kernel()->set_idle_exit();
}
missive_handler_t the_handlers[] = {
recv_cell_handler // Index 0. Cells with zero in handler_idx will handle missives with this handler.
};
void mc_workerus_main() {
kernel::set_handlers(1, the_handlers);
cell::separate(mc_out_num_workerus);
missive::separate(mc_out_num_workerus);
agent_ref::separate(mc_out_num_workerus);
agent_grp::separate(mc_out_num_workerus);
MC_MARK_USED(ker);
mck_slog2("WORKERU (0,0) started\n");
// Next line is just to remaind that every single cell should have a valid handler_idx. It was already 0.
kernel::get_first_cell()->handler_idx = 0; // This is recv_cell_handler's index in the_handlers.
}
mck_slog2("WORKERU (0,1) started\n");
mc_workeru_id_t dst = mc_ro_co_to_id(0, 0);
missive* msv = missive::acquire();
msv->src = act1;
msv->dst = act2;
msv->send();
mck_slog2("SENT MISSIVE\n");
ker->set_idle_exit();
}
mck_slog2("FINISHED !!\n");
}