template<class T>
void bindFlag(T& value, const char* name, const char* description)
{
- using namespace std;
declareFlag<T>(name, description, value, [&value](T const& val) {
value = val;
});
XBT_LOG_EXTERNAL_CATEGORY(s4u);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity,s4u,"S4U activities");
-using namespace simgrid;
-s4u::Activity::Activity() {
+namespace simgrid {
+namespace s4u {
+
+Activity::Activity() {
}
-s4u::Activity::~Activity() {
+Activity::~Activity() {
}
-void s4u::Activity::setRemains(double remains) {
+void Activity::setRemains(double remains) {
xbt_assert(state_ == inited, "Cannot change the remaining amount of work once the Activity is started");
remains_ = remains;
}
+}
+}
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor,"S4U actors");
-using namespace simgrid;
+namespace simgrid {
+namespace s4u {
-s4u::Actor::Actor(const char* name, s4u::Host *host, double killTime, std::function<void()> code)
+Actor::Actor(const char* name, s4u::Host *host, double killTime, std::function<void()> code)
{
// TODO, when autorestart is used, the std::function is copied so the new
// instance will get a fresh (reinitialized) state. Is this what we want?
killTime, nullptr, 0));
}
-s4u::Actor::Actor(const char* name, s4u::Host *host, double killTime,
+Actor::Actor(const char* name, s4u::Host *host, double killTime,
const char* function, std::vector<std::string> args)
{
simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
killTime, nullptr, 0));
}
-void s4u::Actor::join() {
+void Actor::join() {
simcall_process_join(pimpl_, -1);
}
-void s4u::Actor::setAutoRestart(bool autorestart) {
+void Actor::setAutoRestart(bool autorestart) {
simcall_process_auto_restart_set(pimpl_,autorestart);
}
-s4u::Host *s4u::Actor::getHost() {
+s4u::Host *Actor::getHost() {
return s4u::Host::by_name(sg_host_get_name(simcall_process_get_host(pimpl_)));
}
-const char* s4u::Actor::getName() {
+const char* Actor::getName() {
return simcall_process_get_name(pimpl_);
}
-int s4u::Actor::getPid(){
+int Actor::getPid(){
return simcall_process_get_PID(pimpl_);
}
-void s4u::Actor::setKillTime(double time) {
+void Actor::setKillTime(double time) {
simcall_process_set_kill_time(pimpl_,time);
}
-double s4u::Actor::getKillTime() {
+double Actor::getKillTime() {
return simcall_process_get_kill_time(pimpl_);
}
-void s4u::Actor::kill(int pid) {
+void Actor::kill(int pid) {
msg_process_t process = SIMIX_process_from_PID(pid);
if(process != nullptr) {
simcall_process_kill(process);
}
}
-void s4u::Actor::kill() {
+void Actor::kill() {
simcall_process_kill(pimpl_);
}
-simgrid::s4u::Actor s4u::Actor::forPid(int pid)
+simgrid::s4u::Actor Actor::forPid(int pid)
{
// Should we throw if we did not find it?
smx_process_t process = SIMIX_process_from_PID(pid);
// static stuff:
-void s4u::Actor::killAll() {
+void Actor::killAll() {
simcall_process_killall(1);
}
-
-namespace simgrid {
-namespace s4u {
namespace this_actor {
void sleep(double duration) {
#include "simgrid/s4u/comm.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm,s4u_activity,"S4U asynchronous communications");
-using namespace simgrid;
-s4u::Comm::~Comm() {
+namespace simgrid {
+namespace s4u {
+
+Comm::~Comm() {
}
-s4u::Comm &s4u::Comm::send_init(s4u::Mailbox &chan) {
+s4u::Comm &Comm::send_init(s4u::Mailbox &chan) {
s4u::Comm *res = new s4u::Comm();
res->sender_ = SIMIX_process_self();
res->mailbox_ = &chan;
return *res;
}
-s4u::Comm &s4u::Comm::recv_init(s4u::Mailbox &chan) {
+s4u::Comm &Comm::recv_init(s4u::Mailbox &chan) {
s4u::Comm *res = new s4u::Comm();
res->receiver_ = SIMIX_process_self();
res->mailbox_ = &chan;
return *res;
}
-void s4u::Comm::setRate(double rate) {
+void Comm::setRate(double rate) {
xbt_assert(state_==inited);
rate_ = rate;
}
-void s4u::Comm::setSrcData(void * buff) {
+void Comm::setSrcData(void * buff) {
xbt_assert(state_==inited);
xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
srcBuff_ = buff;
}
-void s4u::Comm::setSrcDataSize(size_t size){
+void Comm::setSrcDataSize(size_t size){
xbt_assert(state_==inited);
srcBuffSize_ = size;
}
-void s4u::Comm::setSrcData(void * buff, size_t size) {
+void Comm::setSrcData(void * buff, size_t size) {
xbt_assert(state_==inited);
xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
srcBuff_ = buff;
srcBuffSize_ = size;
}
-void s4u::Comm::setDstData(void ** buff) {
+void Comm::setDstData(void ** buff) {
xbt_assert(state_==inited);
xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
dstBuff_ = buff;
}
-size_t s4u::Comm::getDstDataSize(){
+size_t Comm::getDstDataSize(){
xbt_assert(state_==finished);
return dstBuffSize_;
}
-void s4u::Comm::setDstData(void ** buff, size_t size) {
+void Comm::setDstData(void ** buff, size_t size) {
xbt_assert(state_==inited);
xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
dstBuffSize_ = size;
}
-void s4u::Comm::start() {
+void Comm::start() {
xbt_assert(state_ == inited);
if (srcBuff_ != nullptr) { // Sender side
}
state_ = started;
}
-void s4u::Comm::wait() {
+void Comm::wait() {
xbt_assert(state_ == started || state_ == inited);
if (state_ == started)
}
state_ = finished;
}
-void s4u::Comm::wait(double timeout) {
+void Comm::wait(double timeout) {
xbt_assert(state_ == started || state_ == inited);
if (state_ == started) {
state_ = finished;
}
-s4u::Comm &s4u::Comm::send_async(Mailbox &dest, void *data, int simulatedSize) {
+s4u::Comm &Comm::send_async(Mailbox &dest, void *data, int simulatedSize) {
s4u::Comm &res = s4u::Comm::send_init(dest);
res.setRemains(simulatedSize);
res.srcBuff_ = data;
return res;
}
-s4u::Comm &s4u::Comm::recv_async(Mailbox &dest, void **data) {
+s4u::Comm &Comm::recv_async(Mailbox &dest, void **data) {
s4u::Comm &res = s4u::Comm::recv_init(dest);
res.setDstData(data);
res.start();
return res;
}
+}
+}
#include "simgrid/s4u/conditionVariable.hpp"
#include "simgrid/simix.h"
-using namespace simgrid;
+namespace simgrid {
+namespace s4u {
-s4u::ConditionVariable::ConditionVariable() : cond_(simcall_cond_init()){
+ConditionVariable::ConditionVariable() : cond_(simcall_cond_init()){
}
-s4u::ConditionVariable::~ConditionVariable() {
+ConditionVariable::~ConditionVariable() {
SIMIX_cond_unref(cond_);
}
/**
* Wait functions
*/
-void s4u::ConditionVariable::wait(std::unique_lock<Mutex>& lock) {
+void ConditionVariable::wait(std::unique_lock<Mutex>& lock) {
simcall_cond_wait(cond_, lock.mutex()->mutex_);
}
}
}
-std::cv_status s4u::ConditionVariable::wait_until(std::unique_lock<Mutex>& lock, double timeout_time)
+std::cv_status ConditionVariable::wait_until(std::unique_lock<Mutex>& lock, double timeout_time)
{
double now = SIMIX_get_clock();
double timeout;
/**
* Notify functions
*/
-void s4u::ConditionVariable::notify_one() {
+void ConditionVariable::notify_one() {
simcall_cond_signal(cond_);
}
-void s4u::ConditionVariable::notify_all() {
+void ConditionVariable::notify_all() {
simcall_cond_broadcast(cond_);
}
-
+}
+}
#include "simgrid/s4u/mailbox.hpp"
#include "simgrid/s4u/storage.hpp"
+#include "surf/surf.h" // routing_platf. FIXME:KILLME. SOON
+#include "src/surf/surf_routing.hpp" // routing_platf. FIXME:KILLME. SOON
+
XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
-using namespace simgrid;
-s4u::Engine *s4u::Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
+namespace simgrid {
+namespace s4u {
+Engine *Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
-s4u::Engine::Engine(int *argc, char **argv) {
+
+Engine::Engine(int *argc, char **argv) {
xbt_assert(s4u::Engine::instance_ == nullptr, "It is currently forbidden to create more than one instance of s4u::Engine");
s4u::Engine::instance_ = this;
SIMIX_global_init(argc, argv);
}
-s4u::Engine *s4u::Engine::instance() {
+Engine *Engine::instance() {
if (s4u::Engine::instance_ == nullptr)
new Engine(0,nullptr);
return s4u::Engine::instance_;
}
-void s4u::Engine::shutdown() {
+void Engine::shutdown() {
delete s4u::Engine::instance_;
s4u::Engine::instance_ = nullptr;
delete s4u::Mailbox::mailboxes;
delete s4u::Storage::storages_;
}
-double s4u::Engine::getClock()
+double Engine::getClock()
{
return SIMIX_get_clock();
}
-void s4u::Engine::loadPlatform(const char *platf)
+void Engine::loadPlatform(const char *platf)
{
SIMIX_create_environment(platf);
}
-void s4u::Engine::registerFunction(const char*name, int (*code)(int,char**))
+void Engine::registerFunction(const char*name, int (*code)(int,char**))
{
SIMIX_function_register(name,code);
}
-void s4u::Engine::registerDefault(int (*code)(int,char**))
+void Engine::registerDefault(int (*code)(int,char**))
{
SIMIX_function_register_default(code);
}
-void s4u::Engine::loadDeployment(const char *deploy)
+void Engine::loadDeployment(const char *deploy)
{
SIMIX_launch_application(deploy);
}
-void s4u::Engine::run() {
+void Engine::run() {
if (MC_is_active()) {
MC_run();
} else {
}
}
-#include "surf/surf.h" // routing_platf. FIXME:KILLME. SOON
-#include "src/surf/surf_routing.hpp" // routing_platf. FIXME:KILLME. SOON
-
-s4u::As *s4u::Engine::rootAs()
+s4u::As *Engine::rootAs()
{
return routing_platf->root_; // FIXME: get the root into the Engine directly (and kill the platf)
}
}
return nullptr;
}
+
/** @brief Retrieve the AS of the given name (or nullptr if not found) */
-s4u::As *s4u::Engine::asByNameOrNull(const char *name) {
+As *Engine::asByNameOrNull(const char *name) {
return asByNameRecursive(rootAs(),name);
}
+}
+}
XBT_LOG_EXTERNAL_CATEGORY(s4u);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_channel,s4u,"S4U Communication Mailboxes");
-
-using namespace simgrid;
+namespace simgrid {
+namespace s4u {
boost::unordered_map <std::string, s4u::Mailbox *> *s4u::Mailbox::mailboxes = new boost::unordered_map<std::string, s4u::Mailbox*> ();
-
-s4u::Mailbox::Mailbox(const char*name, smx_mailbox_t inferior) {
+Mailbox::Mailbox(const char*name, smx_mailbox_t inferior) {
pimpl_ = inferior;
name_ = name;
mailboxes->insert({name, this});
}
-const char *s4u::Mailbox::getName() {
+const char *Mailbox::getName() {
return name_.c_str();
}
-s4u::Mailbox *s4u::Mailbox::byName(const char*name) {
+Mailbox *Mailbox::byName(const char*name) {
s4u::Mailbox *res;
try {
res = mailboxes->at(name);
return res;
}
-bool s4u::Mailbox::empty() {
+bool Mailbox::empty() {
return nullptr == simcall_mbox_front(pimpl_);
}
-void s4u::Mailbox::setReceiver(smx_process_t process) {
+void Mailbox::setReceiver(smx_process_t process) {
simcall_mbox_set_receiver(pimpl_, process);
}
/** @brief get the receiver (process associated to the mailbox) */
-smx_process_t s4u::Mailbox::receiver() {
+smx_process_t Mailbox::receiver() {
return pimpl_->permanent_receiver;
}
+}
+}
+
/*------- C functions -------*/
sg_mbox_t sg_mbox_by_name(const char*name){
- return s4u::Mailbox::byName(name);
+ return simgrid::s4u::Mailbox::byName(name);
}
int sg_mbox_is_empty(sg_mbox_t mbox) {
return mbox->empty();
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
static void IB_create_host_callback(simgrid::s4u::Host& host){
- using namespace simgrid::surf;
+ using simgrid::surf::NetworkIBModel;
+ using simgrid::surf::IBNode;
static int id=0;
// pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives
simgrid::surf::NetworkAction *action,
simgrid::surf::Action::State statein, simgrid::surf::Action::State stateout)
{
- using namespace simgrid::surf;
+ using simgrid::surf::NetworkIBModel;
+ using simgrid::surf::IBNode;
+
if(statein!=simgrid::surf::Action::State::running || stateout!=simgrid::surf::Action::State::done)
return;
std::pair<IBNode*,IBNode*> pair = ((NetworkIBModel*)surf_network_model)->active_comms[action];