+/* Copyright (c) 2017. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
#include <iostream>
#include <simgrid/s4u.hpp>
#include <stdlib.h>
static void receiver()
{
- simgrid::s4u::MailboxPtr mymailbox = simgrid::s4u::Mailbox::byName("receiver_mailbox");
- simgrid::s4u::MailboxPtr theirmailbox = simgrid::s4u::Mailbox::byName("sender_mailbox");
+ simgrid::s4u::MailboxPtr mymailbox = simgrid::s4u::Mailbox::byName("receiver_mailbox");
std::vector<simgrid::s4u::CommPtr> pending_comms;
static void sender()
{
- simgrid::s4u::MailboxPtr mymailbox = simgrid::s4u::Mailbox::byName("sender_mailbox");
simgrid::s4u::MailboxPtr theirmailbox = simgrid::s4u::Mailbox::byName("receiver_mailbox");
void* data = (void*)"data";
simgrid::s4u::Engine* engine = new simgrid::s4u::Engine(&argc, argv);
- if (argc < 2) {
- std::cerr << "Usage: " << argv[0] << " <xml platform file>" << std::endl;
- exit(1);
- }
+ xbt_assert(argc >= 2, "Usage: %s <xml platform file>", argv[0]);
engine->loadPlatform(argv[1]);
- simgrid::s4u::Host* host = simgrid::s4u::Host::by_name("Tremblay");
-
- simgrid::s4u::Actor::createActor("Receiver", host, receiver);
- simgrid::s4u::Actor::createActor("Sender", host, sender);
+ simgrid::s4u::Host** hosts = sg_host_list();
+ simgrid::s4u::Actor::createActor("Receiver", hosts[0], receiver);
+ simgrid::s4u::Actor::createActor("Sender", hosts[1], sender);
+ xbt_free(hosts);
- simgrid::s4u::Engine::instance()->run();
+ engine->run();
+ delete engine;
return 0;
}