From 9abfa55c584ef8f2e6049ec2b03ffff56a3d6f43 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 12 Aug 2015 21:44:15 +0200 Subject: [PATCH] actually rename s4u::Process into s4u::Actor --- examples/s4u/dumb/s4u_test.cpp | 8 +-- include/simgrid/s4u.h | 2 +- .../simgrid/s4u/{process.hpp => actor.hpp} | 66 +++++++++---------- include/simgrid/s4u/engine.hpp | 6 +- include/simgrid/s4u/host.hpp | 16 ++--- include/simgrid/s4u/mailbox.hpp | 4 +- src/s4u/{s4u_process.cpp => s4u_actor.cpp} | 54 +++++++-------- tools/cmake/DefinePackages.cmake | 4 +- 8 files changed, 80 insertions(+), 80 deletions(-) rename include/simgrid/s4u/{process.hpp => actor.hpp} (50%) rename src/s4u/{s4u_process.cpp => s4u_actor.cpp} (53%) diff --git a/examples/s4u/dumb/s4u_test.cpp b/examples/s4u/dumb/s4u_test.cpp index 51001e349a..6087684e1e 100644 --- a/examples/s4u/dumb/s4u_test.cpp +++ b/examples/s4u/dumb/s4u_test.cpp @@ -10,10 +10,10 @@ using namespace s4u; XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category"); -class Worker : Process { +class Worker : Actor { public: Worker(const char*procname, Host *host,int argc, char **argv) - : s4u::Process(procname,host,argc,argv){} + : s4u::Actor(procname,host,argc,argv){} int main(int argc, char **argv) { XBT_INFO("Hello s4u, I'm ready to serve"); @@ -25,10 +25,10 @@ public: } }; -class Master : Process { +class Master : Actor { public: Master(const char*procname, Host *host,int argc, char **argv) - : Process(procname,host,argc,argv){} + : Actor(procname,host,argc,argv){} int main(int argc, char **argv) { XBT_INFO("Hello s4u, I have something to send"); diff --git a/include/simgrid/s4u.h b/include/simgrid/s4u.h index 674214213a..5844847dc6 100644 --- a/include/simgrid/s4u.h +++ b/include/simgrid/s4u.h @@ -6,9 +6,9 @@ #ifndef SIMGRID_S4U_S4U_H #define SIMGRID_S4U_S4U_H +#include "s4u/actor.hpp" #include "s4u/mailbox.hpp" #include "simgrid/s4u/engine.hpp" #include "simgrid/s4u/host.hpp" -#include "simgrid/s4u/process.hpp" #endif /* SIMGRID_S4U_S4U_H */ diff --git a/include/simgrid/s4u/process.hpp b/include/simgrid/s4u/actor.hpp similarity index 50% rename from include/simgrid/s4u/process.hpp rename to include/simgrid/s4u/actor.hpp index b8a9fb16f7..ec7e421fc5 100644 --- a/include/simgrid/s4u/process.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -3,8 +3,8 @@ /* 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. */ -#ifndef SIMGRID_S4U_PROCESS_HPP -#define SIMGRID_S4U_PROCESS_HPP +#ifndef SIMGRID_S4U_ACTOR_HPP +#define SIMGRID_S4U_ACTOR_HPP #include "simgrid/simix.h" @@ -16,20 +16,20 @@ class Mailbox; /** @brief Simulation Agent * - * A process may be defined as a code executing in a location (host). + * An actor may be defined as a code executing in a location (host). * - * All processes should be started from the XML deployment file (using the @link{s4u::Engine::loadDeployment()}), - * even if you can also start new processes directly. + * All actors should be started from the XML deployment file (using the @link{s4u::Engine::loadDeployment()}), + * even if you can also start new actors directly. * Separating the deployment in the XML from the logic in the code is a good habit as it makes your simulation easier * to adapt to new settings. * - * The code that you define for a given process should be placed in the main method that is virtual. - * For example, a Worker process should be declared as follows: + * The code that you define for a given actor should be placed in the main method that is virtual. + * For example, a Worker actor should be declared as follows: * * \verbatim - * #include "s4u/process.hpp" + * #include "s4u/actor.hpp" * - * class Worker : simgrid::s4u::Process { + * class Worker : simgrid::s4u::Actor { * * int main(int argc, char **argv) { * printf("Hello s4u"); @@ -38,56 +38,56 @@ class Mailbox; * \endverbatim * */ -class Process { +class Actor { public: - Process(const char*procname, s4u::Host *host, int argc, char **argv); - Process(const char*procname, s4u::Host *host, int argc, char **argv, double killTime); - virtual ~Process() {} + Actor(const char*name, s4u::Host *host, int argc, char **argv); + Actor(const char*name, s4u::Host *host, int argc, char **argv, double killTime); + virtual ~Actor() {} /** The main method of your agent */ virtual int main(int argc, char **argv)=0; - /** The process that is currently running */ - static Process *current(); - /** Retrieves the process that have the given PID (or NULL if not existing) */ - static Process *byPid(int pid); + /** The Actor that is currently running */ + static Actor *current(); + /** Retrieves the actor that have the given PID (or NULL if not existing) */ + static Actor *byPid(int pid); - /** Retrieves the name of that process */ + /** Retrieves the name of that actor */ const char*getName(); - /** Retrieves the host on which that process is running */ + /** Retrieves the host on which that actor is running */ s4u::Host *getHost(); - /** Retrieves the PID of that process */ + /** Retrieves the PID of that actor */ int getPid(); - /** If set to true, the process will automatically restart when its host reboots */ + /** If set to true, the actor will automatically restart when its host reboots */ void setAutoRestart(bool autorestart); - /** Sets the time at which that process should be killed */ + /** Sets the time at which that actor should be killed */ void setKillTime(double time); - /** Retrieves the time at which that process will be killed (or -1 if not set) */ + /** Retrieves the time at which that actor will be killed (or -1 if not set) */ double getKillTime(); - /** Ask kindly to all processes to die. Only the issuer will survive. */ + /** Ask kindly to all actors to die. Only the issuer will survive. */ static void killAll(); - /** Ask the process to die. + /** Ask the actor to die. * * It will only notice your request when doing a simcall next time (a communication or similar). - * SimGrid sometimes have issues when you kill processes that are currently communicating and such. We are working on it to fix the issues. + * SimGrid sometimes have issues when you kill actors that are currently communicating and such. We are working on it to fix the issues. */ void kill(); - /** Block the process sleeping for that amount of seconds (may throws hostFailure) */ + /** Block the actor sleeping for that amount of seconds (may throws hostFailure) */ void sleep(double duration); - /** Block the process, computing the given amount of flops */ + /** Block the actor, computing the given amount of flops */ void execute(double flop); - /** Block the process until it gets a message from the given mailbox */ + /** Block the actor until it gets a message from the given mailbox */ //void* recv(const char *mailbox); - /** Block the process until it gets a string message (to be freed after use) from the given mailbox */ + /** Block the actor until it gets a string message (to be freed after use) from the given mailbox */ char *recvstr(Mailbox &chan); - /** Block the process until it delivers a string message (that will be copied) to the given mailbox */ + /** Block the actor until it delivers a string message (that will be copied) to the given mailbox */ void sendstr(Mailbox &chan, const char*msg); protected: @@ -97,11 +97,11 @@ private: }; }} // namespace simgrid::s4u -#endif /* SIMGRID_S4U_PROCESS_HPP */ +#endif /* SIMGRID_S4U_ACTOR_HPP */ #if 0 -public abstract class Process implements Runnable { +public abstract class Actor implements Runnable { /** Suspends the process. See {@link #resume()} to resume it afterward */ public native void suspend(); /** Resume a process that was suspended by {@link #suspend()}. */ diff --git a/include/simgrid/s4u/engine.hpp b/include/simgrid/s4u/engine.hpp index 7c2f9aff3c..96ef4dcd40 100644 --- a/include/simgrid/s4u/engine.hpp +++ b/include/simgrid/s4u/engine.hpp @@ -24,17 +24,17 @@ public: */ void loadPlatform(const char *platf); - /** Registers the main function of a process that will be launched from the deployment file */ + /** Registers the main function of an actor that will be launched from the deployment file */ void register_function(const char*name, int (*code)(int,char**)); - /** Registers a function as the default main function of processes + /** Registers a function as the default main function of actors * * It will be used as fallback when the function requested from the deployment file was not registered. * It is used for trace-based simulations (see examples/msg/actions). */ void register_default(int (*code)(int,char**)); - /** @brief Load a deployment file and launch the processes that it contains */ + /** @brief Load a deployment file and launch the actors that it contains */ void loadDeployment(const char *deploy); /** @brief Run the simulation */ diff --git a/include/simgrid/s4u/host.hpp b/include/simgrid/s4u/host.hpp index 54399ece84..6998b87429 100644 --- a/include/simgrid/s4u/host.hpp +++ b/include/simgrid/s4u/host.hpp @@ -13,9 +13,9 @@ namespace simgrid { namespace s4u { -class Process; +class Actor; -/** @brief Simulated machine that can host some processes +/** @brief Simulated machine that can host some actors * * It represents some physical resource with computing and networking capabilities. * @@ -24,7 +24,7 @@ class Process; * You cannot create a host yourself. * * You can retrieve a particular host using @link{simgrid::s4u::Host.byName()}, - * and processes can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}. + * and actors can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}. */ class Host { private: @@ -32,18 +32,18 @@ private: public: /** Retrieves an host from its name. */ static s4u::Host *byName(std::string name); - /** Retrieves the host on which the current process is running */ + /** Retrieves the host on which the current actor is running */ static s4u::Host *current(); const char* getName(); - /** Turn sthat host on if it was previously off + /** Turns that host on if it was previously off * - * All processes on that host which were marked autorestart will be restarted automatically. + * All actors on that host which were marked autorestart will be restarted automatically. * This call does nothing if the host is already on. */ void turnOn(); - /** Turns that host off. All processes are forcefully stopped. */ + /** Turns that host off. All actors are forcefully stopped. */ void turnOff(); /** Returns if that host is currently up and running */ bool isOn(); @@ -55,7 +55,7 @@ public: void* getData() {return p_userdata;} protected: - friend Process; + friend Actor; sg_host_t getInferior() {return p_sghost;} private: void*p_userdata=NULL; diff --git a/include/simgrid/s4u/mailbox.hpp b/include/simgrid/s4u/mailbox.hpp index c76a4d9ec2..cb3369ffe9 100644 --- a/include/simgrid/s4u/mailbox.hpp +++ b/include/simgrid/s4u/mailbox.hpp @@ -8,7 +8,7 @@ #include -#include "simgrid/s4u/process.hpp" +#include "actor.hpp" namespace simgrid { namespace s4u { @@ -21,7 +21,7 @@ namespace s4u { * sender and receiver. */ class Mailbox { - friend Process; + friend Actor; private: Mailbox(const char*name, smx_rdv_t inferior); diff --git a/src/s4u/s4u_process.cpp b/src/s4u/s4u_actor.cpp similarity index 53% rename from src/s4u/s4u_process.cpp rename to src/s4u/s4u_actor.cpp index b75cd58cbe..8d4f299385 100644 --- a/src/s4u/s4u_process.cpp +++ b/src/s4u/s4u_actor.cpp @@ -4,22 +4,22 @@ /* 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/actor.hpp" #include "../../include/simgrid/s4u/mailbox.hpp" #include "xbt/log.h" #include "msg/msg_private.h" #include "msg/msg_mailbox.h" #include "simgrid/s4u/host.hpp" -#include "simgrid/s4u/process.hpp" -XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_process,"S4U processes"); +XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor,"S4U actors"); -/* C main function of a process, running this->main */ -static int s4u_process_runner(int argc, char **argv) { +/* C main function of a actor, running this->main */ +static int s4u_actor_runner(int argc, char **argv) { smx_process_t smx_proc = SIMIX_process_self(); - simgrid::s4u::Process *proc = (simgrid::s4u::Process*) SIMIX_process_self_get_data(smx_proc); - int res= proc->main(argc,argv); + simgrid::s4u::Actor *actor = (simgrid::s4u::Actor*) SIMIX_process_self_get_data(smx_proc); + int res = actor->main(argc,argv); return res; } @@ -27,61 +27,61 @@ static int s4u_process_runner(int argc, char **argv) { using namespace simgrid; -s4u::Process::Process(const char *procname, s4u::Host *host, int argc, char **argv) - : s4u::Process::Process(procname,host, argc,argv, -1) { +s4u::Actor::Actor(const char *name, s4u::Host *host, int argc, char **argv) + : s4u::Actor::Actor(name,host, argc,argv, -1) { } -s4u::Process::Process(const char *procname, s4u::Host *host, int argc, char **argv, double killTime) { - p_smx_process = simcall_process_create(procname, s4u_process_runner, this, host->getName(), killTime, argc, argv, NULL/*properties*/,0); +s4u::Actor::Actor(const char *name, s4u::Host *host, int argc, char **argv, double killTime) { + p_smx_process = simcall_process_create(name, s4u_actor_runner, this, host->getName(), killTime, argc, argv, NULL/*properties*/,0); - xbt_assert(p_smx_process,"Cannot create the process"); + xbt_assert(p_smx_process,"Cannot create the actor"); // TRACE_msg_process_create(procname, simcall_process_get_PID(p_smx_process), host->getInferior()); // simcall_process_on_exit(p_smx_process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,p_smx_process); } -s4u::Process *s4u::Process::current() { +s4u::Actor *s4u::Actor::current() { smx_process_t smx_proc = SIMIX_process_self(); - return (simgrid::s4u::Process*) SIMIX_process_self_get_data(smx_proc); + return (simgrid::s4u::Actor*) SIMIX_process_self_get_data(smx_proc); } -s4u::Process *s4u::Process::byPid(int pid) { - return (simgrid::s4u::Process*) SIMIX_process_self_get_data(SIMIX_process_from_PID(pid)); +s4u::Actor *s4u::Actor::byPid(int pid) { + return (simgrid::s4u::Actor*) SIMIX_process_self_get_data(SIMIX_process_from_PID(pid)); } -void s4u::Process::setAutoRestart(bool autorestart) { +void s4u::Actor::setAutoRestart(bool autorestart) { simcall_process_auto_restart_set(p_smx_process,autorestart); } -s4u::Host *s4u::Process::getHost() { +s4u::Host *s4u::Actor::getHost() { return s4u::Host::byName(sg_host_name(simcall_process_get_host(p_smx_process))); } -const char* s4u::Process::getName() { +const char* s4u::Actor::getName() { return simcall_process_get_name(p_smx_process); } -int s4u::Process::getPid(){ +int s4u::Actor::getPid(){ return simcall_process_get_PID(p_smx_process); } -void s4u::Process::setKillTime(double time) { +void s4u::Actor::setKillTime(double time) { simcall_process_set_kill_time(p_smx_process,time); } -double s4u::Process::getKillTime() { +double s4u::Actor::getKillTime() { return simcall_process_get_kill_time(p_smx_process); } -void s4u::Process::killAll() { +void s4u::Actor::killAll() { simcall_process_killall(1); } -void s4u::Process::kill() { +void s4u::Actor::kill() { simcall_process_kill(p_smx_process); } -void s4u::Process::sleep(double duration) { +void s4u::Actor::sleep(double duration) { simcall_process_sleep(duration); } -void s4u::Process::execute(double flops) { +void s4u::Actor::execute(double flops) { simcall_process_execute(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/); } -char *s4u::Process::recvstr(Mailbox &chan) { +char *s4u::Actor::recvstr(Mailbox &chan) { char *res=NULL; size_t res_size=sizeof(res); @@ -89,7 +89,7 @@ char *s4u::Process::recvstr(Mailbox &chan) { return res; } -void s4u::Process::sendstr(Mailbox &chan, const char*msg) { +void s4u::Actor::sendstr(Mailbox &chan, const char*msg) { char *msg_cpy=xbt_strdup(msg); smx_synchro_t comm = simcall_comm_isend(p_smx_process, chan.getInferior(), strlen(msg), -1/*rate*/, msg_cpy, sizeof(void *), diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index f563ee1971..459c7dc96e 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -379,10 +379,10 @@ else() endif() set(S4U_SRC + src/s4u/s4u_actor.cpp src/s4u/s4u_engine.cpp src/s4u/s4u_host.cpp src/s4u/s4u_mailbox.cpp - src/s4u/s4u_process.cpp ) set(SIMGRID_SRC @@ -690,10 +690,10 @@ set(headers_to_install include/simgrid/simix.h include/simgrid/host.h include/simgrid/link.h + include/simgrid/s4u/actor.hpp include/simgrid/s4u/engine.hpp include/simgrid/s4u/host.hpp include/simgrid/s4u/mailbox.hpp - include/simgrid/s4u/process.hpp include/simgrid/s4u.h include/smpi/mpi.h include/smpi/smpi.h -- 2.20.1