X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b9684d3607aa558c95b7185ddf147b478a7e367f..3e978b7ee3fb648f19de9aeb4450a98e30dd437b:/examples/s4u/basic/s4u_basic.h diff --git a/examples/s4u/basic/s4u_basic.h b/examples/s4u/basic/s4u_basic.h new file mode 100644 index 0000000000..7a3f9c6bed --- /dev/null +++ b/examples/s4u/basic/s4u_basic.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2006-2016. 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 + +#include "simgrid/s4u.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category"); + +class Worker { +public: + Worker() {}; + Worker(simgrid::xbt::args args) {} + void operator()() { + XBT_INFO("Hello s4u, I'm ready to serve"); + char *msg = static_cast(simgrid::s4u::this_actor::recv( + *simgrid::s4u::Mailbox::byName("worker"))); + XBT_INFO("I received '%s'",msg); + XBT_INFO("I'm done. See you."); + } +}; + +class Master { +public: + Master() {}; + Master(simgrid::xbt::args args) {} + void operator()() { + const char *msg = "GaBuZoMeu"; + XBT_INFO("Hello s4u, I have something to send"); + simgrid::s4u::this_actor::send(*simgrid::s4u::Mailbox::byName("worker"), xbt_strdup(msg), strlen(msg)); + XBT_INFO("I'm done. See you."); + } +};