class Context;
class ContextFactory;
}
+namespace actor {
+class ActorImpl;
+using ActorImplPtr = boost::intrusive_ptr<ActorImpl>;
+} // namespace actor
namespace activity {
class ActivityImpl;
using ActivityImplPtr = boost::intrusive_ptr<ActivityImpl>;
}
}
namespace simix {
- class ActorImpl;
- using ActorImplPtr = boost::intrusive_ptr<ActorImpl>;
class Host;
}
typedef simgrid::trace_mgr::trace tmgr_Trace;
typedef simgrid::kernel::context::Context* smx_context_t;
-typedef simgrid::simix::ActorImpl* smx_actor_t;
+typedef simgrid::kernel::actor::ActorImpl* smx_actor_t;
typedef simgrid::kernel::activity::MutexImpl* smx_mutex_t;
typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t;
typedef simgrid::surf::StorageImpl* surf_storage_t;
class XBT_PUBLIC Actor : public simgrid::xbt::Extendable<Actor> {
friend Exec;
friend Mailbox;
- friend simgrid::simix::ActorImpl;
+ friend simgrid::kernel::actor::ActorImpl;
friend simgrid::kernel::activity::MailboxImpl;
- simix::ActorImpl* pimpl_ = nullptr;
+ kernel::actor::ActorImpl* pimpl_ = nullptr;
/** Wrap a (possibly non-copyable) single-use task into a `std::function` */
template<class F, class... Args>
static void killAll(int resetPid);
/** Returns the internal implementation of this actor */
- simix::ActorImpl* getImpl();
+ kernel::actor::ActorImpl* getImpl();
/** Retrieve the property value (or nullptr if not set) */
std::map<std::string, std::string>* getProperties();
XBT_PUBLIC const std::vector<smx_actor_t>& process_get_runnable();
-XBT_PUBLIC void set_maestro(std::function<void()> code);
-XBT_PUBLIC void create_maestro(std::function<void()> code);
-
// What's executed as SIMIX actor code:
typedef std::function<void()> ActorCode;
simgrid::s4u::Mailbox piface_; // Our interface
simgrid::xbt::string name_;
- simgrid::simix::ActorImplPtr permanent_receiver; // process to which the mailbox is attached
+ simgrid::kernel::actor::ActorImplPtr permanent_receiver; // actor to which the mailbox is attached
boost::circular_buffer_space_optimized<smx_activity_t> comm_queue;
boost::circular_buffer_space_optimized<smx_activity_t> done_comm_queue; // messages already received in the permanent receive mode
};
bool locked = false;
smx_actor_t owner = nullptr;
// List of sleeping processes:
- simgrid::simix::SynchroList sleeping;
+ simgrid::kernel::actor::SynchroList sleeping;
// boost::intrusive_ptr<Mutex> support:
friend void intrusive_ptr_add_ref(MutexImpl* mutex)
~VirtualMachineImpl();
/** @brief Suspend the VM */
- virtual void suspend(simgrid::simix::ActorImpl* issuer);
+ virtual void suspend(simgrid::kernel::actor::ActorImpl* issuer);
/** @brief Resume the VM */
virtual void resume();
/** @brief Shutdown the VM */
- virtual void shutdown(simgrid::simix::ActorImpl* issuer);
+ virtual void shutdown(simgrid::kernel::actor::ActorImpl* issuer);
/** @brief Change the physical host on which the given VM is running */
virtual void setPm(s4u::Host* dest);
ActorPtr Actor::createActor(const char* name, s4u::Host* host, std::function<void()> code)
{
- simgrid::simix::ActorImpl* actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
+ simgrid::kernel::actor::ActorImpl* actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
return actor->iface();
}
{
simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
simgrid::simix::ActorCode code = factory(std::move(args));
- simgrid::simix::ActorImpl* actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
+ simgrid::kernel::actor::ActorImpl* actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
return actor->iface();
}
namespace simgrid {
-namespace simix {
+namespace kernel {
+namespace actor {
ActorImpl::~ActorImpl()
{
// retrieve the arguments of the old process
// FIXME: Factorize this with SIMIX_host_add_auto_restart_process ?
- simgrid::simix::ProcessArg arg;
+ simgrid::kernel::actor::ProcessArg arg;
arg.name = name;
arg.code = code;
arg.host = host;
{
smx_actor_t maestro = nullptr;
/* Create maestro process and initialize it */
- maestro = new simgrid::simix::ActorImpl();
+ maestro = new simgrid::kernel::actor::ActorImpl();
maestro->pid = simix_process_maxpid++;
maestro->name = "";
maestro->userdata = nullptr;
simix_global->maestro_process = maestro;
}
+} // namespace actor
}
}
/** @brief Creates and runs the maestro process */
void SIMIX_maestro_create(void (*code)(void*), void* data)
{
- simgrid::simix::create_maestro(std::bind(code, data));
+ simgrid::kernel::actor::create_maestro(std::bind(code, data));
}
/**
return nullptr;
}
- smx_actor_t process = new simgrid::simix::ActorImpl();
+ smx_actor_t process = new simgrid::kernel::actor::ActorImpl();
xbt_assert(code && host != nullptr, "Invalid parameters");
/* Process data */
return nullptr;
}
- smx_actor_t process = new simgrid::simix::ActorImpl();
+ smx_actor_t process = new simgrid::kernel::actor::ActorImpl();
/* Process data */
process->pid = simix_process_maxpid++;
process->name = std::string(name);
};
namespace simgrid {
-namespace simix {
+namespace kernel {
+namespace actor {
class ProcessArg {
public:
typedef boost::intrusive::list<ActorImpl, boost::intrusive::member_hook<ActorImpl, boost::intrusive::list_member_hook<>,
&ActorImpl::smx_synchro_hook>>
SynchroList;
+
+XBT_PUBLIC void set_maestro(std::function<void()> code);
+XBT_PUBLIC void create_maestro(std::function<void()> code);
}
-}
+} // namespace kernel
+} // namespace simgrid
-typedef simgrid::simix::ActorImpl* smx_actor_t;
+typedef simgrid::kernel::actor::ActorImpl* smx_actor_t;
extern "C" {
// Either create a new context with maestro or create
// a context object with the current context mestro):
- simgrid::simix::create_maestro(maestro_code);
+ simgrid::kernel::actor::create_maestro(maestro_code);
/* Prepare to display some more info when dying on Ctrl-C pressing */
signal(SIGINT, inthandler);
double kill_time, std::map<std::string, std::string>* properties,
int auto_restart)
{
- simgrid::simix::ProcessArg* arg =
- new simgrid::simix::ProcessArg(name, code, data, host, kill_time, nullptr, auto_restart);
+ simgrid::kernel::actor::ProcessArg* arg =
+ new simgrid::kernel::actor::ProcessArg(name, code, data, host, kill_time, nullptr, auto_restart);
arg->properties.reset(properties, [](decltype(properties)) {});
if (host->isOff() && watched_hosts.find(host->getCname()) == watched_hosts.end()) {
/** @brief Restart the list of processes that have been registered to the host */
void SIMIX_host_autorestart(sg_host_t host)
{
- std::vector<simgrid::simix::ProcessArg*> process_list =
+ std::vector<simgrid::kernel::actor::ProcessArg*> process_list =
host->extension<simgrid::simix::Host>()->auto_restart_processes;
for (auto const& arg : process_list) {
-/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2018. 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. */
explicit Host();
virtual ~Host();
- boost::intrusive::list<ActorImpl, boost::intrusive::member_hook<ActorImpl, boost::intrusive::list_member_hook<>,
- &ActorImpl::host_process_list_hook>>
+ boost::intrusive::list<kernel::actor::ActorImpl,
+ boost::intrusive::member_hook<kernel::actor::ActorImpl, boost::intrusive::list_member_hook<>,
+ &kernel::actor::ActorImpl::host_process_list_hook>>
process_list;
- std::vector<ProcessArg*> auto_restart_processes;
- std::vector<ProcessArg*> boot_processes;
+ std::vector<kernel::actor::ProcessArg*> auto_restart_processes;
+ std::vector<kernel::actor::ProcessArg*> boot_processes;
void turnOn();
};
std::vector<smx_actor_t> process_to_run;
std::vector<smx_actor_t> process_that_ran;
std::map<aid_t, smx_actor_t> process_list;
- boost::intrusive::list<ActorImpl, boost::intrusive::member_hook<ActorImpl, boost::intrusive::list_member_hook<>,
- &ActorImpl::smx_destroy_list_hook>>
+ boost::intrusive::list<kernel::actor::ActorImpl,
+ boost::intrusive::member_hook<kernel::actor::ActorImpl, boost::intrusive::list_member_hook<>,
+ &kernel::actor::ActorImpl::smx_destroy_list_hook>>
process_to_destroy;
#if SIMGRID_HAVE_MC
/* MCer cannot read members process_list and process_to_destroy above in the remote process, so we copy the info it
std::vector<simgrid::xbt::Task<void()>> tasks;
std::vector<simgrid::xbt::Task<void()>> tasksTemp;
- std::vector<simgrid::simix::ActorImpl*> daemons;
+ std::vector<simgrid::kernel::actor::ActorImpl*> daemons;
};
}
}
/** @brief Ask to the provided ActorImpl to raise the provided exception */
#define SMX_EXCEPTION(issuer, cat, val, msg) \
if (1) { \
- simgrid::simix::ActorImpl* _smx_throw_issuer = (issuer); /* evaluate only once */ \
+ simgrid::kernel::actor::ActorImpl* _smx_throw_issuer = (issuer); /* evaluate only once */ \
xbt_ex e(XBT_THROW_POINT, msg); \
e.category = cat; \
e.value = val; \
_smx_throw_issuer->exception = std::make_exception_ptr(e); \
} else \
- ((void)0)
+ ((void)0)
}
#endif
std::atomic_int_fast32_t refcount_{1};
smx_mutex_t mutex = nullptr;
- simgrid::simix::SynchroList sleeping; /* list of sleeping processes */
+ simgrid::kernel::actor::SynchroList sleeping; /* list of sleeping processes */
simgrid::s4u::ConditionVariable cond_;
};
struct s_smx_sem_t {
unsigned int value;
- simgrid::simix::SynchroList sleeping; /* list of sleeping processes */
+ simgrid::kernel::actor::SynchroList sleeping; /* list of sleeping processes */
};
XBT_PRIVATE void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall);
std::function<void()> code = factory(std::move(actor->args));
std::shared_ptr<std::map<std::string, std::string>> properties(actor->properties);
- simgrid::simix::ProcessArg* arg =
- new simgrid::simix::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
+ simgrid::kernel::actor::ProcessArg* arg =
+ new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
host->extension<simgrid::simix::Host>()->boot_processes.push_back(arg);
if (start_time > SIMIX_get_clock()) {
- arg = new simgrid::simix::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
+ arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->getCname(), start_time);
SIMIX_timer_set(start_time, [arg, auto_restart]() {