XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->get_cname());
- const std::string* msg1 = static_cast<std::string*>(mailbox->get());
- const std::string* msg2 = static_cast<std::string*>(mailbox->get());
- const std::string* msg3 = static_cast<std::string*>(mailbox->get());
+ const auto* msg1 = static_cast<std::string*>(mailbox->get());
+ const auto* msg2 = static_cast<std::string*>(mailbox->get());
+ const auto* msg3 = static_cast<std::string*>(mailbox->get());
XBT_INFO("I received '%s', '%s' and '%s'", msg1->c_str(), msg2->c_str(), msg3->c_str());
delete msg1;
delete msg2;
xbt_assert(argc >= 3, "Actor forwarder requires 2 parameters, but got only %d", argc - 1);
simgrid::s4u::Mailbox* in = simgrid::s4u::Mailbox::by_name(argv[1]);
simgrid::s4u::Mailbox* out = simgrid::s4u::Mailbox::by_name(argv[2]);
- std::string* msg = static_cast<std::string*>(in->get());
+ auto* msg = static_cast<std::string*>(in->get());
XBT_INFO("Forward '%s'.", msg->c_str());
out->put(msg, msg->size());
}
{
simgrid::s4u::Mailbox* tracker_mailbox = simgrid::s4u::Mailbox::by_name(TRACKER_MAILBOX);
// Build the task to send to the tracker
- TrackerQuery* peer_request = new TrackerQuery(id, mailbox_);
+ auto* peer_request = new TrackerQuery(id, mailbox_);
try {
XBT_DEBUG("Sending a peer request to the tracker.");
tracker_mailbox->put(peer_request, TRACKER_COMM_SIZE, GET_PEERS_TIMEOUT);
}
try {
- TrackerAnswer* answer = static_cast<TrackerAnswer*>(mailbox_->get(GET_PEERS_TIMEOUT));
+ auto* answer = static_cast<TrackerAnswer*>(mailbox_->get(GET_PEERS_TIMEOUT));
// Add the peers the tracker gave us to our peer list.
for (auto const& peer_id : answer->getPeers())
if (id != peer_id)
{
for (auto const& kv : connected_peers) {
const Connection& remote_peer = kv.second;
- Message* handshake = new Message(MESSAGE_HANDSHAKE, id, mailbox_);
+ auto* handshake = new Message(MESSAGE_HANDSHAKE, id, mailbox_);
remote_peer.mailbox_->put_init(handshake, MESSAGE_HANDSHAKE_SIZE)->detach();
XBT_DEBUG("Sending a HANDSHAKE to %d", remote_peer.id);
}
if (comm->test()) {
// Retrieve the data sent by the peer.
xbt_assert(received != nullptr);
- TrackerQuery* tq = static_cast<TrackerQuery*>(received);
+ auto* tq = static_cast<TrackerQuery*>(received);
// Add the peer to our peer list, if not already known.
if (known_peers.find(tq->getPeerId()) == known_peers.end()) {
}
// Sending back peers to the requesting peer
- TrackerAnswer* ta = new TrackerAnswer(TRACKER_QUERY_INTERVAL);
+ auto* ta = new TrackerAnswer(TRACKER_QUERY_INTERVAL);
std::set<int>::iterator next_peer;
int nb_known_peers = static_cast<int>(known_peers.size());
int max_tries = std::min(MAXIMUM_PEERS, nb_known_peers);
void joinChain()
{
- const ChainMessage* msg = static_cast<ChainMessage*>(me->get());
+ const auto* msg = static_cast<ChainMessage*>(me->get());
prev = msg->prev_;
next = msg->next_;
total_pieces = msg->num_pieces;
{
XBT_DEBUG("peer");
- Peer* p = new Peer();
+ auto* p = new Peer();
double start_time = simgrid::s4u::Engine::get_clock();
p->joinChain();
{
XBT_DEBUG("broadcaster");
- Broadcaster* bc = new Broadcaster(hostcount, piece_count);
+ auto* bc = new Broadcaster(hostcount, piece_count);
bc->buildChain();
bc->sendFile();
{
double compute_cost;
do {
- const double* msg = static_cast<double*>(mailbox->get());
+ const auto* msg = static_cast<double*>(mailbox->get());
compute_cost = *msg;
delete msg;
double compute_cost;
do {
- const double* msg = static_cast<double*>(mailbox->get());
+ const auto* msg = static_cast<double*>(mailbox->get());
compute_cost = *msg;
delete msg;
XBT_INFO("Ping from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str());
/* - Do the ping with a 1-Byte payload (latency bound) ... */
- double* payload = new double();
- *payload = simgrid::s4u::Engine::get_clock();
+ auto* payload = new double(simgrid::s4u::Engine::get_clock());
mailbox_out->put(payload, 1);
/* - ... then wait for the (large) pong */
- const double* sender_time = static_cast<double*>(mailbox_in->get());
+ const auto* sender_time = static_cast<double*>(mailbox_in->get());
double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
XBT_INFO("Payload received : large communication (bandwidth bound)");
XBT_INFO("Pong from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str());
/* - Receive the (small) ping first ....*/
- const double* sender_time = static_cast<double*>(mailbox_in->get());
+ const auto* sender_time = static_cast<double*>(mailbox_in->get());
double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
XBT_INFO("Payload received : small communication (latency bound)");
XBT_INFO("Ping time (latency bound) %f", communication_time);
delete sender_time;
/* - ... Then send a 1GB pong back (bandwidth bound) */
- double* payload = new double();
- *payload = simgrid::s4u::Engine::get_clock();
+ auto* payload = new double(simgrid::s4u::Engine::get_clock());
XBT_INFO("payload = %.3f", *payload);
mailbox_out->put(payload, 1e9);
XBT_INFO("Host \"%u\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox->get_cname());
std::string msg = "Token";
neighbor_mailbox->put(&msg, token_size);
- const std::string* res = static_cast<std::string*>(my_mailbox->get());
+ const auto* res = static_cast<std::string*>(my_mailbox->get());
XBT_INFO("Host \"%u\" received \"%s\"", rank, res->c_str());
} else {
- std::string* res = static_cast<std::string*>(my_mailbox->get());
+ auto* res = static_cast<std::string*>(my_mailbox->get());
XBT_INFO("Host \"%u\" received \"%s\"", rank, res->c_str());
XBT_INFO("Host \"%u\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox->get_cname());
neighbor_mailbox->put(res, token_size);
{
simgrid::s4u::Host* pm0 = simgrid::s4u::Host::by_name("Fafard");
- simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
- simgrid::s4u::VirtualMachine* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
+ auto* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
vm0->start();
vm1->start();
test_two_activities(pm0, pm0);
XBT_INFO(" ");
- simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ auto* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
vm0->start();
XBT_INFO("# 3. Put a single activity on a VM. ");
simgrid::s4u::Host* pm1 = simgrid::s4u::Host::by_name("Tremblay");
simgrid::s4u::Host* pm2 = simgrid::s4u::Host::by_name("Bourassa");
- simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ auto* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
vm0->set_ramsize(1e9); // 1Gbytes
vm0->start();
vm0->destroy();
- vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
- simgrid::s4u::VirtualMachine* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
+ vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
vm0->set_ramsize(1e9); // 1Gbytes
vm1->set_ramsize(1e9); // 1Gbytes
static void communication_tx_fun(std::vector<std::string> args)
{
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(args.at(0));
- s_payload* payload = new s_payload;
+ auto* payload = new s_payload;
payload->tx_actor_name = simgrid::s4u::Actor::self()->get_cname();
payload->tx_host = simgrid::s4u::this_actor::get_host();
payload->clock_sta = simgrid::s4u::Engine::get_clock();
const char* host_name = simgrid::s4u::this_actor::get_host()->get_cname();
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(args.at(0));
- const s_payload* payload = static_cast<struct s_payload*>(mbox->get());
+ const auto* payload = static_cast<struct s_payload*>(mbox->get());
double clock_end = simgrid::s4u::Engine::get_clock();
XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->get_cname(), payload->tx_actor_name, host_name, actor_name,
"## Test 2 (started): check impact of running an activity inside a VM (there is no degradation for the moment)");
XBT_INFO("### Put a VM on a PM, and put an activity to the VM");
- simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ auto* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
vm0->start();
launch_computation_worker(vm0);
simgrid::s4u::this_actor::sleep_for(2);
XBT_INFO("### Put two VMs on a PM, and put an activity to each VM");
vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
vm0->start();
- simgrid::s4u::VirtualMachine* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
+ auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
launch_computation_worker(vm0);
launch_computation_worker(vm1);
simgrid::s4u::this_actor::sleep_for(2);
static void sender(simgrid::s4u::Mailbox* mailbox)
{
- double* computation_amount = new double();
- *computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+ auto* computation_amount = new double(simgrid::s4u::this_actor::get_host()->get_speed());
simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(2 * (*computation_amount));
simgrid::s4u::CommPtr comm = mailbox->put_init(computation_amount, 7e6);
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
std::string msgName =
std::string("Message ") + std::to_string(i) + std::string(" from peer ") + std::to_string(my_id);
- std::string* payload = new std::string(msgName); // copy the data we send:
+ auto* payload = new std::string(msgName); // copy the data we send:
// 'msgName' is not a stable storage location
XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
/* Create a communication representing the ongoing communication */
if (peer_id != my_id) {
std::string mboxName = std::string("peer-") + std::to_string(peer_id);
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
- std::string* payload = new std::string("finalize"); // Make a copy of the data we will send
+ auto* payload = new std::string("finalize"); // Make a copy of the data we will send
pending_comms.push_back(mbox->put_async(payload, msg_size));
XBT_INFO("Send 'finalize' to 'peer-%d'", peer_id);
}
while (pending_finalize_messages > 0) {
if (my_mbox->ready()) {
double start = simgrid::s4u::Engine::get_clock();
- const std::string* received = static_cast<std::string*>(my_mbox->get());
+ const auto* received = static_cast<std::string*>(my_mbox->get());
double waiting_time = simgrid::s4u::Engine::get_clock() - start;
xbt_assert(
waiting_time == 0,
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
- std::string* payload = new std::string("Sent message");
+ auto* payload = new std::string("Sent message");
/* Create a communication representing the ongoing communication and then */
simgrid::s4u::CommPtr comm = mbox->put_init(payload, 13194230);
XBT_INFO("Wait for the message.");
void* payload = mbox->get();
- const std::string* received = static_cast<std::string*>(payload);
+ const auto* received = static_cast<std::string*>(payload);
XBT_INFO("I got '%s'.", received->c_str());
delete received;
std::string msg_content = std::string("Message ") + std::to_string(i);
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
- std::string* payload = new std::string(msg_content);
+ auto* payload = new std::string(msg_content);
/* Create a communication representing the ongoing communication and then */
simgrid::s4u::CommPtr comm = mbox->put_async(payload, msg_size);
comm->wait();
}
- const std::string* received = static_cast<std::string*>(payload);
+ const auto* received = static_cast<std::string*>(payload);
XBT_INFO("I got a '%s'.", received->c_str());
if (*received == "finalize")
cont = false; // If it's a finalize message, we're done.
std::string msg_content = std::string("Message ") + std::to_string(i);
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets it
- std::string* payload = new std::string(msg_content);
+ auto* payload = new std::string(msg_content);
XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname());
{
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
- const std::string* received = static_cast<std::string*>(mbox->get());
+ const auto* received = static_cast<std::string*>(mbox->get());
XBT_INFO("I got a '%s'.", received->c_str());
cont = (*received != "finalize"); // If it's a finalize message, we're done
// Receiving the message was all we were supposed to do
std::string msg_content = std::string("Message ") + std::to_string(i);
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets it
- std::string* payload = new std::string(msg_content);
+ auto* payload = new std::string(msg_content);
XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname());
{
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
- const std::string* received = static_cast<std::string*>(mbox->get());
+ const auto* received = static_cast<std::string*>(mbox->get());
XBT_INFO("I got a '%s'.", received->c_str());
cont = (*received != "finalize"); // If it's a finalize message, we're done
// Receiving the message was all we were supposed to do
std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count);
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
std::string msgName = std::string("Message ") + std::to_string(i);
- std::string* payload = new std::string(msgName); // copy the data we send:
+ auto* payload = new std::string(msgName); // copy the data we send:
// 'msgName' is not a stable storage location
XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
for (int i = 0; i < receivers_count; i++) {
std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count);
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
- std::string* payload = new std::string("finalize"); // Make a copy of the data we will send
+ auto* payload = new std::string("finalize"); // Make a copy of the data we will send
simgrid::s4u::CommPtr comm = mbox->put_async(payload, 0);
pending_comms.push_back(comm);
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
- const std::string* received = static_cast<std::string*>(mbox->get());
+ const auto* received = static_cast<std::string*>(mbox->get());
XBT_INFO("I got a '%s'.", received->c_str());
if (*received == "finalize")
cont = false; // If it's a finalize message, we're done.
void Node::notifyAndQuit()
{
// send the PREDECESSOR_LEAVING to our successor
- ChordMessage* pred_msg = new ChordMessage(PREDECESSOR_LEAVING);
+ auto* pred_msg = new ChordMessage(PREDECESSOR_LEAVING);
pred_msg->request_id = pred_id_;
pred_msg->answer_to = mailbox_;
if (pred_id_ != -1 && pred_id_ != id_) {
// send the SUCCESSOR_LEAVING to our predecessor (only if I have one that is not me)
- ChordMessage* succ_msg = new ChordMessage(SUCCESSOR_LEAVING);
+ auto* succ_msg = new ChordMessage(SUCCESSOR_LEAVING);
succ_msg->request_id = fingers_[0];
succ_msg->answer_to = mailbox_;
XBT_DEBUG("Sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_));
simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive");
- ChordMessage* message = new ChordMessage(PREDECESSOR_ALIVE);
+ auto* message = new ChordMessage(PREDECESSOR_ALIVE);
message->request_id = pred_id_;
message->answer_to = return_mailbox;
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred");
- ChordMessage* message = new ChordMessage(GET_PREDECESSOR);
+ auto* message = new ChordMessage(GET_PREDECESSOR);
message->request_id = id_;
message->answer_to = return_mailbox;
try {
comm->wait_for(timeout);
- const ChordMessage* answer = static_cast<ChordMessage*>(data);
+ const auto* answer = static_cast<ChordMessage*>(data);
XBT_DEBUG("Received the answer to my 'Get Predecessor' request: the predecessor of node %d is %d", ask_to,
answer->answer_id);
predecessor_id = answer->answer_id;
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ");
- ChordMessage* message = new ChordMessage(FIND_SUCCESSOR);
+ auto* message = new ChordMessage(FIND_SUCCESSOR);
message->request_id = id_;
message->answer_to = return_mailbox;
/* Notifies a remote node that its predecessor may have changed. */
void Node::remoteNotify(int notify_id, int predecessor_candidate_id) const
{
- ChordMessage* message = new ChordMessage(NOTIFY);
+ auto* message = new ChordMessage(NOTIFY);
message->request_id = predecessor_candidate_id;
message->answer_to = nullptr;
if (comm_completed) {
if (data != nullptr) {
- ChordMessage* message = static_cast<ChordMessage*>(data);
+ auto* message = static_cast<ChordMessage*>(data);
handleMessage(message);
data = nullptr;
}
namespace kademlia {
static void destroy(void* message)
{
- const Message* msg = static_cast<Message*>(message);
+ const auto* msg = static_cast<Message*>(message);
delete msg->answer_;
delete msg;
}
XBT_DEBUG("Received an answer from the node I know.");
got_answer = true;
// retrieve the node list and ping them.
- const Message* msg = static_cast<Message*>(received_msg);
+ const auto* msg = static_cast<Message*>(received_msg);
node_list = msg->answer_;
if (node_list) {
for (auto const& contact : node_list->getNodes())
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id));
/* Build the task */
- Message* msg = new Message(id_, destination, simgrid::s4u::Mailbox::by_name(std::to_string(id_)),
- simgrid::s4u::Host::current()->get_cname());
+ auto* msg = new Message(id_, destination, simgrid::s4u::Mailbox::by_name(std::to_string(id_)),
+ simgrid::s4u::Host::current()->get_cname());
/* Send the task */
mailbox->put_init(msg, 1)->detach(kademlia::destroy);
*/
Answer* Node::findClosest(unsigned int destination_id)
{
- Answer* answer = new Answer(destination_id);
+ auto* answer = new Answer(destination_id);
/* We find the corresponding bucket for the id */
const Bucket* bucket = table.findBucket(destination_id);
int bucket_id = bucket->getId();
receive_comm = mailbox->get_async(&received_msg);
if (receive_comm->test()) {
- const Message* msg = static_cast<Message*>(received_msg);
+ const auto* msg = static_cast<Message*>(received_msg);
// Check if what we have received is what we are looking for.
if (msg->answer_ && msg->answer_->getDestinationId() == id_to_find) {
routingTableUpdate(msg->sender_id_);
XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->get_cname(),
msg->issuer_host_name_.c_str(), msg->destination_id_);
// Building the answer to the request
- Message* answer =
+ auto* answer =
new Message(id_, msg->destination_id_, findClosest(msg->destination_id_),
simgrid::s4u::Mailbox::by_name(std::to_string(id_)), simgrid::s4u::Host::current()->get_cname());
// Sending the answer
if (node.receive_comm->test()) {
// There has been a message, we need to handle it !
- const kademlia::Message* msg = static_cast<kademlia::Message*>(node.received_msg);
+ const auto* msg = static_cast<kademlia::Message*>(node.received_msg);
if (msg) {
node.handleFindNode(msg);
delete msg->answer_;
void* res = mailbox->get();
xbt_free(res);
} else {
- void** data= new void*[flow_amount];
+ auto* data = new void*[flow_amount];
// Start all comms in parallel, and wait for their completion in one shot
std::vector<simgrid::s4u::CommPtr> comms;
/* Host 1 */
XBT_INFO("Creating and starting two VMs");
- simgrid::s4u::VirtualMachine* vm_host1 = new simgrid::s4u::VirtualMachine("vm_host1", host1, 1);
+ auto* vm_host1 = new simgrid::s4u::VirtualMachine("vm_host1", host1, 1);
vm_host1->start();
- simgrid::s4u::VirtualMachine* vm_host2 = new simgrid::s4u::VirtualMachine("vm_host2", host2, 1);
+ auto* vm_host2 = new simgrid::s4u::VirtualMachine("vm_host2", host2, 1);
vm_host2->start();
XBT_INFO("Create two activities on Host1: both inside a VM");
/* - Attach some user data to disk1 */
XBT_INFO("*** Get/set data for storage element: Disk1 ***");
- const std::string* data = static_cast<std::string*>(disk->get_data());
+ const auto* data = static_cast<std::string*>(disk->get_data());
XBT_INFO("Get storage data: '%s'", data ? data->c_str() : "No user data");
// Open an non-existing file to create it
std::string filename = "/scratch/tmp/data.txt";
- simgrid::s4u::File* file = new simgrid::s4u::File(filename, nullptr);
+ auto* file = new simgrid::s4u::File(filename, nullptr);
sg_size_t write = file->write(200000); // Write 200,000 bytes
XBT_INFO("Create a %llu bytes file named '%s' on /scratch", write, filename.c_str());
// Test attaching some user data to the file
file->set_data(new std::string("777"));
- const std::string* file_data = static_cast<std::string*>(file->get_data());
+ const auto* file_data = static_cast<std::string*>(file->get_data());
XBT_INFO("User data attached to the file: %s", file_data->c_str());
delete file_data;
static void sender()
{
ensure_root_tid();
- std::string* payload = new std::string("some message");
+ auto* payload = new std::string("some message");
simgrid::s4u::Mailbox::by_name("some mailbox")->put((void*)payload, 10e8);
}
{
ensure_other_tid();
- const std::string* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
+ const auto* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
XBT_INFO("Task received");
delete payload;
}
XBT_INFO("Propositions changed : r=1, cs=0");
}
- const Message* grant = static_cast<Message*>(my_mailbox->get());
+ const auto* grant = static_cast<Message*>(my_mailbox->get());
if ((id == 1) && (grant->kind == Message::Kind::GRANT)) {
cs = 1;
static void client(int id)
{
- int* payload = new int();
- *payload = id;
+ auto* payload = new int(id);
simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload, 10000);
XBT_INFO("Sent!");
static void client(int id)
{
- int* payload1 = new int();
- *payload1 = id;
- int* payload2 = new int();
- *payload2 = id;
+ auto* payload1 = new int(id);
+ auto* payload2 = new int(id);
XBT_INFO("Send %d", id);
simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload1, 10000);
static void client(int id)
{
- int* payload = new int();
- *payload = id;
+ auto* payload = new int(id);
simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload, 10000);
XBT_INFO("Sent!");
}
int value_got = -1;
simgrid::s4u::Mailbox* mb = simgrid::s4u::Mailbox::by_name("server");
for (int count = 0; count < worker_amount; count++) {
- const int* msg = static_cast<int*>(mb->get());
+ const auto* msg = static_cast<int*>(mb->get());
value_got = *msg;
delete msg;
}
XBT_DEBUG("Worker started");
- const double* payload = static_cast<double*>(mbox->get());
+ const auto* payload = static_cast<double*>(mbox->get());
count_finished--;
if (count_finished == 0) {
for (int i = 0; i < number_of_tasks; i++) {
mailbox = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(i % workers_count));
- double* payload = new double(comp_size);
+ auto* payload = new double(comp_size);
try {
XBT_INFO("Send a message to %s", mailbox->get_cname());
mailbox->put(payload, comm_size, 10.0);
for (int i = 0; i < workers_count; i++) {
/* - Eventually tell all the workers to stop by sending a "finalize" task */
mailbox = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(i));
- double* payload = new double(-1.0);
+ auto* payload = new double(-1.0);
try {
mailbox->put(payload, 0, 1.0);
} catch (const simgrid::TimeoutException&) {
while (true) {
try {
XBT_INFO("Waiting a message on %s", mailbox->get_cname());
- const double* payload = static_cast<double*>(mailbox->get());
+ const auto* payload = static_cast<double*>(mailbox->get());
xbt_assert(payload != nullptr, "mailbox->get() failed");
double comp_size = *payload;
delete payload;
static void send(simgrid::xbt::ReplayAction& action)
{
- uint64_t size = static_cast<uint64_t>(std::stod(action[3]));
- std::string* payload = new std::string(action[3]);
+ auto size = static_cast<uint64_t>(std::stod(action[3]));
+ auto* payload = new std::string(action[3]);
double clock = simgrid::s4u::Engine::get_clock();
simgrid::s4u::Mailbox* to = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_name() + "_" + action[2]);
ACT_DEBUG("Entering Send: %s (size: %" PRIu64 ") -- Actor %s on mailbox %s", NAME.c_str(), size,
std::string full_name = simgrid::s4u::this_actor::get_name() + ":" + file_name;
ACT_DEBUG("Entering Open: %s (filename: %s)", NAME.c_str(), file_name.c_str());
- simgrid::s4u::File* file = new simgrid::s4u::File(file_name, NULL);
+ auto* file = new simgrid::s4u::File(file_name, NULL);
opened_files.insert({full_name, file});
int main(int argc, char **argv)
{
- std::vector<std::string> args = std::vector<std::string>({"one", "two", "three", ""});
+ std::vector<std::string> args({"one", "two", "three", ""});
simgrid::s4u::Engine e(&argc, argv);
e.load_platform("../../platforms/two_hosts.xml");
simgrid::s4u::Actor::create("producer", simgrid::s4u::Host::by_name("Tremblay"), producer, &args);
static void pop_some_processes(int nb_processes, simgrid::s4u::Host* host)
{
for (int i = 0; i < nb_processes; ++i) {
- int* param = new int;
- *param = i + 1;
+ auto* param = new int(i + 1);
simgrid::s4u::Actor::create("meh", host, sleeper_process, param);
}
}
double compute_cost;
do {
- const double* msg = static_cast<double*>(mailbox->get());
+ const auto* msg = static_cast<double*>(mailbox->get());
compute_cost = *msg;
delete msg;