X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6dfbeafc01f45baadb4214d15cd0c703887d743e..67d8461e1530fcf03ba924c15a97eba2550d78e0:/src/simix/ActorImpl.hpp diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index e7dd3b0d06..06d42dc7da 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-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. */ @@ -7,15 +7,16 @@ #define SIMIX_ACTORIMPL_H #include "simgrid/s4u/Actor.hpp" -#include "src/simix/popping_private.h" +#include "src/simix/popping_private.hpp" +#include "src/surf/PropertyHolder.hpp" #include "xbt/swag.h" #include +#include -typedef struct s_smx_process_exit_fun { +struct s_smx_process_exit_fun_t { int_f_pvoid_pvoid_t fun; void *arg; -} s_smx_process_exit_fun_t; -typedef s_smx_process_exit_fun_t* smx_process_exit_fun_t; +}; namespace simgrid { namespace simix { @@ -27,11 +28,11 @@ public: void *data = nullptr; sg_host_t host = nullptr; double kill_time = 0.0; - xbt_dict_t properties = nullptr; + std::shared_ptr> properties; bool auto_restart = false; }; -class ActorImpl { +class ActorImpl : public simgrid::surf::PropertyHolder { public: ActorImpl() : piface_(this) {} ~ActorImpl(); @@ -45,7 +46,8 @@ public: aid_t pid = 0; aid_t ppid = -1; simgrid::xbt::string name; - const char* cname() { return name.c_str(); } + const simgrid::xbt::string& getName() const { return name; } + const char* getCname() const { return name.c_str(); } s4u::Host* host = nullptr; /* the host on which the process is running */ smx_context_t context = nullptr; /* the context (uctx/raw/thread) that executes the user function */ @@ -56,12 +58,11 @@ public: bool suspended = false; bool auto_restart = false; - sg_host_t new_host = nullptr; /* if not null, the host on which the process must migrate to */ + sg_host_t new_host = nullptr; /* if not null, the host on which the process must migrate to */ smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */ std::list comms; /* the current non-blocking communication synchros */ - xbt_dict_t properties = nullptr; s_smx_simcall_t simcall; - void *data = nullptr; /* kept for compatibility, it should be replaced with moddata */ + void* userdata = nullptr; /* kept for compatibility, it should be replaced with moddata */ std::vector on_exit; /* list of functions executed when the process dies */ std::function code; @@ -106,7 +107,12 @@ public: void daemonize(); bool isDaemon() { return daemon; } /** Whether this actor has been daemonized */ bool isSuspended() { return suspended; } + simgrid::s4u::Actor* restart(); + smx_activity_t suspend(ActorImpl* issuer); void resume(); + smx_activity_t sleep(double duration); + void setUserData(void* data) { userdata = data; } + void* getUserData() { return userdata; } }; } @@ -116,15 +122,11 @@ typedef simgrid::simix::ProcessArg *smx_process_arg_t; typedef simgrid::simix::ActorImpl* smx_actor_t; -SG_BEGIN_DECL() +extern "C" { -XBT_PRIVATE smx_actor_t SIMIX_process_create( - const char *name, - std::function code, - void *data, - sg_host_t host, - xbt_dict_t properties, - smx_actor_t parent_process); +XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, std::function code, void* data, sg_host_t host, + std::map* properties, + smx_actor_t parent_process); XBT_PRIVATE void SIMIX_process_runall(); XBT_PRIVATE void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer); @@ -138,15 +140,11 @@ XBT_PRIVATE void SIMIX_process_set_data(smx_actor_t process, void *data); XBT_PRIVATE smx_actor_t SIMIX_process_get_by_name(const char* name); XBT_PRIVATE void SIMIX_process_auto_restart_set(smx_actor_t process, int auto_restart); -XBT_PRIVATE smx_actor_t SIMIX_process_restart(smx_actor_t process, smx_actor_t issuer); extern void (*SMPI_switch_data_segment)(int dest); - -SG_END_DECL() +} XBT_PRIVATE void SIMIX_process_sleep_destroy(smx_activity_t synchro); -XBT_PRIVATE smx_activity_t SIMIX_process_suspend(smx_actor_t process, smx_actor_t issuer); XBT_PRIVATE smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, double timeout); -XBT_PRIVATE smx_activity_t SIMIX_process_sleep(smx_actor_t process, double duration); #endif