simgrid::s4u::this_actor::sleep_for(1);
XBT_INFO("Killing everybody but myself");
- simgrid::s4u::Actor::killAll();
+ simgrid::s4u::Actor::kill_all();
XBT_INFO("OK, goodbye now. I commit a suicide.");
simgrid::s4u::this_actor::kill();
XBT_INFO(" Zone property: author -> %s", root->getProperty("author"));
/* Get the property list of current bob process */
- std::map<std::string, std::string>* props = simgrid::s4u::Actor::self()->getProperties();
+ std::map<std::string, std::string>* props = simgrid::s4u::Actor::self()->get_properties();
const char* noexist = "UnknownProcessProp";
XBT_ATTRIB_UNUSED const char* value;
XBT_INFO("== Try to get an actor property that does not exist");
- value = simgrid::s4u::Actor::self()->getProperty(noexist);
- xbt_assert(not value, "The property is defined (it shouldnt)");
+ value = simgrid::s4u::Actor::self()->get_property(noexist);
+ xbt_assert(not value, "The property is defined (it should not)");
return 0;
}
/** Retrieves the PID of that actor
*
* aid_t is an alias for long */
- aid_t get_pid();
+ aid_t get_pid() const;
/** Retrieves the PPID of that actor
*
* aid_t is an alias for long */
- aid_t get_ppid();
+ aid_t get_ppid() const;
/** Suspend an actor by suspending the task on which it was waiting for the completion. */
void suspend();
void yield();
/** Returns true if the actor is suspended. */
- int isSuspended();
+ int is_suspended();
/** If set to true, the actor will automatically restart when its host reboots */
- void setAutoRestart(bool autorestart);
+ void set_auto_restart(bool autorestart);
/** Add a function to the list of "on_exit" functions for the current actor. The on_exit functions are the functions
* executed when your actor is killed. You should use them to free the data used by your actor.
*/
- void onExit(int_f_pvoid_pvoid_t fun, void* data);
+ void on_exit(int_f_pvoid_pvoid_t fun, void* data);
/** Sets the time at which that actor should be killed */
- void setKillTime(double time);
+ void set_kill_time(double time);
/** Retrieves the time at which that actor will be killed (or -1 if not set) */
- double getKillTime();
+ double get_kill_time();
void migrate(Host * new_host);
static void kill(aid_t pid);
/** Retrieves the actor that have the given PID (or nullptr if not existing) */
- static ActorPtr byPid(aid_t pid);
+ static ActorPtr by_pid(aid_t pid);
/** @brief Wait for the actor to finish.
*
*/
void join();
void join(double timeout);
-
- // Static methods on all actors:
+ Actor* restart();
/** Ask kindly to all actors to die. Only the issuer will survive. */
- static void killAll();
- static void killAll(int resetPid);
+ static void kill_all();
/** Returns the internal implementation of this actor */
- kernel::actor::ActorImpl* getImpl();
+ kernel::actor::ActorImpl* get_impl();
/** Retrieve the property value (or nullptr if not set) */
- std::map<std::string, std::string>* getProperties();
- const char* getProperty(const char* key);
- void setProperty(const char* key, const char* value);
- Actor* restart();
+ std::map<std::string, std::string>* get_properties(); // FIXME: do not export the map, but only the keys or something
+ const char* get_property(const char* key);
+ void set_property(const char* key, const char* value);
XBT_ATTRIB_DEPRECATED_v323("Please use Actor::create()") static ActorPtr
createActor(const char* name, s4u::Host* host, std::function<void()> code)
XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_host()") Host* getHost() { return get_host(); }
XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_pid()") aid_t getPid() { return get_pid(); }
XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_ppid()") aid_t getPpid() { return get_ppid(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::is_suspended()") int isSuspended() { return is_suspended(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::set_auto_restart()") void setAutoRestart(bool a)
+ {
+ set_auto_restart(a);
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::on_exit()") void onExit(int_f_pvoid_pvoid_t fun, void* data)
+ {
+ on_exit(fun, data);
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::set_kill_time()") void setKillTime(double time) { set_kill_time(time); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_kill_time()") double getKillTime() { return get_kill_time(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::by_pid()") static ActorPtr byPid(aid_t pid) { return by_pid(pid); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::kill_all()") static void killAll() { kill_all(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::kill_all() with no parameter") static void killAll(int resetPid)
+ {
+ kill_all();
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_impl()") kernel::actor::ActorImpl* getImpl() { return get_impl(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_property()") const char* getProperty(const char* key)
+ {
+ return get_property(key);
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_properties()") std::map<std::string, std::string>* getProperties()
+ {
+ return get_properties();
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_properties()") void setProperty(const char* key, const char* value)
+ {
+ set_property(key, value);
+ }
};
/** @ingroup s4u_api
friend void intrusive_ptr_release(Mailbox*) {}
public:
/** private function, do not use. FIXME: make me protected */
- kernel::activity::MailboxImpl* getImpl() { return pimpl_; }
+ kernel::activity::MailboxImpl* get_impl() { return pimpl_; }
XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::get_name()") const simgrid::xbt::string& getName() const
{
return get_name();
}
XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::get_cname()") const char* getCname() const { return get_cname(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::get_impl()") kernel::activity::MailboxImpl* getImpl()
+ {
+ return get_impl();
+ }
/** @brief Retrieves the name of that mailbox as a C++ string */
const simgrid::xbt::string& get_name() const;
return;
}
- process->setAutoRestart(jauto_restart == JNI_TRUE);
+ process->set_auto_restart(jauto_restart == JNI_TRUE);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *env, jobject jprocess) {
}
/* true is the process is suspended, false otherwise */
- return (jboolean)process->isSuspended();
+ return (jboolean)process->is_suspended();
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
void MailboxImpl::setReceiver(s4u::ActorPtr actor)
{
if (actor != nullptr)
- this->permanent_receiver = actor.get()->getImpl();
+ this->permanent_receiver = actor.get()->get_impl();
else
this->permanent_receiver = nullptr;
}
void Client::handleRestore(s_mc_message_restore_t* message)
{
#if HAVE_SMPI
- smpi_really_switch_data_segment(simgrid::s4u::Actor::byPid(message->index));
+ smpi_really_switch_data_segment(simgrid::s4u::Actor::by_pid(message->index));
#endif
}
void Client::handleActorEnabled(s_mc_message_actor_enabled_t* msg)
/* Try to receive it by calling SIMIX network layer */
try {
- simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
+ simcall_comm_recv(MSG_process_self()->get_impl(), mailbox->get_impl(), task, nullptr, nullptr, nullptr, nullptr,
+ timeout, rate);
XBT_DEBUG("Got task %s from %s", (*task)->name, mailbox->get_cname());
(*task)->simdata->setNotUsed();
}
/* Send it by calling SIMIX network layer */
smx_activity_t act =
- simcall_comm_isend(myself->getImpl(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate, task,
+ simcall_comm_isend(myself->get_impl(), mailbox->get_impl(), t_simdata->bytes_amount, t_simdata->rate, task,
sizeof(void*), nullptr, cleanup, nullptr, nullptr, detached);
t_simdata->comm = boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(act);
XBT_CRITICAL("MSG_task_irecv() was asked to write in a non empty task struct.");
/* Try to receive it by calling SIMIX network layer */
- msg_comm_t comm =
- new simgrid::msg::Comm(nullptr, task, simcall_comm_irecv(SIMIX_process_self(), mbox->getImpl(), task, nullptr,
- nullptr, nullptr, nullptr, rate));
+ msg_comm_t comm = new simgrid::msg::Comm(
+ nullptr, task,
+ simcall_comm_irecv(SIMIX_process_self(), mbox->get_impl(), task, nullptr, nullptr, nullptr, nullptr, rate));
return comm;
}
/* Try to send it by calling SIMIX network layer */
try {
smx_activity_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simix call */
- comm = simcall_comm_isend(SIMIX_process_self(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate, task,
+ comm = simcall_comm_isend(SIMIX_process_self(), mailbox->get_impl(), t_simdata->bytes_amount, t_simdata->rate, task,
sizeof(void*), nullptr, nullptr, nullptr, nullptr, 0);
if (TRACE_is_enabled())
simcall_set_category(comm, task->category);
smx_actor_t /*parent_process*/)
{
msg_process_t p = MSG_process_create_from_stdfunc(name, std::move(code), data, host, properties);
- return p == nullptr ? nullptr : p->getImpl();
+ return p == nullptr ? nullptr : p->get_impl();
}
/** \ingroup m_process_management
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
/* get from SIMIX the MSG process data, and then the user data */
- simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->getImpl()->userdata;
+ simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->get_impl()->userdata;
if (msgExt)
return msgExt->data;
else
{
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
- static_cast<simgrid::msg::ActorExt*>(process->getImpl()->userdata)->data = data;
+ static_cast<simgrid::msg::ActorExt*>(process->get_impl()->userdata)->data = data;
return MSG_OK;
}
}
smx_context_t MSG_process_get_smx_ctx(msg_process_t process) { // deprecated -- smx_context_t should die afterward
- return process->getImpl()->context;
+ return process->get_impl()->context;
}
/**
* \ingroup m_process_management
*/
XBT_PUBLIC void MSG_process_auto_restart_set(msg_process_t process, int auto_restart)
{
- process->setAutoRestart(auto_restart);
+ process->set_auto_restart(auto_restart);
}
/** @ingroup m_process_management
simcall_process_join(this->pimpl_, timeout);
}
-void Actor::setAutoRestart(bool autorestart) {
+void Actor::set_auto_restart(bool autorestart)
+{
simgrid::simix::kernelImmediate([this, autorestart]() { pimpl_->auto_restart = autorestart; });
}
-void Actor::onExit(int_f_pvoid_pvoid_t fun, void* data)
+void Actor::on_exit(int_f_pvoid_pvoid_t fun, void* data)
{
simcall_process_on_exit(pimpl_, fun, data);
}
return this->pimpl_->get_cname();
}
-aid_t Actor::get_pid()
+aid_t Actor::get_pid() const
{
return this->pimpl_->pid;
}
-aid_t Actor::get_ppid()
+aid_t Actor::get_ppid() const
{
return this->pimpl_->ppid;
}
simgrid::instr::Container::byName(instr_pid(this))->getState("ACTOR_STATE")->popEvent();
}
-int Actor::isSuspended()
+int Actor::is_suspended()
{
return simgrid::simix::kernelImmediate([this] { return pimpl_->suspended; });
}
-void Actor::setKillTime(double time) {
+void Actor::set_kill_time(double time)
+{
simcall_process_set_kill_time(pimpl_,time);
}
/** \brief Get the kill time of an actor(or 0 if unset). */
-double Actor::getKillTime()
+double Actor::get_kill_time()
{
return SIMIX_timer_get_date(pimpl_->kill_timer);
}
[this, process] { SIMIX_process_kill(pimpl_, (pimpl_ == simix_global->maestro_process) ? pimpl_ : process); });
}
-smx_actor_t Actor::getImpl()
+smx_actor_t Actor::get_impl()
{
return pimpl_;
}
// ***** Static functions *****
-ActorPtr Actor::byPid(aid_t pid)
+ActorPtr Actor::by_pid(aid_t pid)
{
smx_actor_t process = SIMIX_process_from_PID(pid);
if (process != nullptr)
return ActorPtr();
}
-void Actor::killAll()
+void Actor::kill_all()
{
simcall_process_killall();
}
-std::map<std::string, std::string>* Actor::getProperties()
+std::map<std::string, std::string>* Actor::get_properties()
{
return simgrid::simix::kernelImmediate([this] { return this->pimpl_->getProperties(); });
}
/** Retrieve the property value (or nullptr if not set) */
-const char* Actor::getProperty(const char* key)
+const char* Actor::get_property(const char* key)
{
return simgrid::simix::kernelImmediate([this, key] { return pimpl_->getProperty(key); });
}
-void Actor::setProperty(const char* key, const char* value)
+void Actor::set_property(const char* key, const char* value)
{
simgrid::simix::kernelImmediate([this, key, value] { pimpl_->setProperty(key, value); });
}
{
/* Do not raise an exception here: this function is called by the logs
* and the exceptions, so it would be called back again and again */
- if (actor == nullptr || actor->getImpl() == nullptr)
+ if (actor == nullptr || actor->get_impl() == nullptr)
return 0;
return actor->get_pid();
}
*/
const char* sg_actor_get_property_value(sg_actor_t actor, const char* name)
{
- return actor->getProperty(name);
+ return actor->get_property(name);
}
/** \ingroup m_actor_management
{
xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
- std::map<std::string, std::string>* props = actor->getProperties();
+ std::map<std::string, std::string>* props = actor->get_properties();
if (props == nullptr)
return nullptr;
for (auto const& elm : *props) {
*/
int sg_actor_is_suspended(sg_actor_t actor)
{
- return actor->isSuspended();
+ return actor->is_suspended();
}
/**
*/
void sg_actor_set_kill_time(sg_actor_t actor, double kill_time)
{
- actor->setKillTime(kill_time);
+ actor->set_kill_time(kill_time);
}
xbt_assert(state_ == State::inited);
if (srcBuff_ != nullptr) { // Sender side
- pimpl_ = simcall_comm_isend(sender_, mailbox_->getImpl(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_,
+ pimpl_ = simcall_comm_isend(sender_, mailbox_->get_impl(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_,
cleanFunction_, copyDataFunction_, user_data_, detached_);
} else if (dstBuff_ != nullptr) { // Receiver side
xbt_assert(not detached_, "Receive cannot be detached");
- pimpl_ = simcall_comm_irecv(receiver_, mailbox_->getImpl(), dstBuff_, &dstBuffSize_, matchFunction_,
+ pimpl_ = simcall_comm_irecv(receiver_, mailbox_->get_impl(), dstBuff_, &dstBuffSize_, matchFunction_,
copyDataFunction_, user_data_, rate_);
} else {
case State::inited: // It's not started yet. Do it in one simcall
if (srcBuff_ != nullptr) {
- simcall_comm_send(sender_, mailbox_->getImpl(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_,
+ simcall_comm_send(sender_, mailbox_->get_impl(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_,
copyDataFunction_, user_data_, timeout);
} else { // Receiver
- simcall_comm_recv(receiver_, mailbox_->getImpl(), dstBuff_, &dstBuffSize_, matchFunction_, copyDataFunction_,
+ simcall_comm_recv(receiver_, mailbox_->get_impl(), dstBuff_, &dstBuffSize_, matchFunction_, copyDataFunction_,
user_data_, timeout, rate_);
}
state_ = State::finished;
ActorPtr me = Actor::self();
if (me == nullptr) // This happens sometimes (eg, when linking against NS3 because it pulls openMPI...)
return nullptr;
- simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->getImpl()->userdata);
+ simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->get_impl()->userdata);
return static_cast<simgrid::smpi::Process*>(msgExt->data);
}
finalization_barrier_ = barrier;
process_ = simgrid::s4u::Actor::self();
- static_cast<simgrid::msg::ActorExt*>(process_->getImpl()->userdata)->data = this;
+ static_cast<simgrid::msg::ActorExt*>(process_->get_impl()->userdata)->data = this;
if (*argc > 3) {
memmove(&(*argv)[0], &(*argv)[2], sizeof(char*) * (*argc - 2));
smx_mailbox_t Process::mailbox()
{
- return mailbox_->getImpl();
+ return mailbox_->get_impl();
}
smx_mailbox_t Process::mailbox_small()
{
- return mailbox_small_->getImpl();
+ return mailbox_small_->get_impl();
}
xbt_mutex_t Process::mailboxes_mutex()
}
if (argc != nullptr && argv != nullptr) {
simgrid::s4u::ActorPtr proc = simgrid::s4u::Actor::self();
- proc->getImpl()->context->set_cleanup(&MSG_process_cleanup_from_SIMIX);
+ proc->get_impl()->context->set_cleanup(&MSG_process_cleanup_from_SIMIX);
char* instance_id = (*argv)[1];
try {
if(MPI_COMM_WORLD!=MPI_COMM_UNINITIALIZED && this!=MPI_COMM_WORLD){
//create leader_communicator
for (i=0; i< leader_group_size;i++)
- leaders_group->set_mapping(simgrid::s4u::Actor::byPid(leader_list[i]), i);
+ leaders_group->set_mapping(simgrid::s4u::Actor::by_pid(leader_list[i]), i);
leader_comm = new Comm(leaders_group, nullptr);
this->set_leaders_comm(leader_comm);
this->set_intra_comm(comm_intra);
// create intracommunicator
}else{
for (i=0; i< leader_group_size;i++)
- leaders_group->set_mapping(simgrid::s4u::Actor::byPid(leader_list[i]), i);
+ leaders_group->set_mapping(simgrid::s4u::Actor::by_pid(leader_list[i]), i);
if(this->get_leaders_comm()==MPI_COMM_NULL){
leader_comm = new Comm(leaders_group, nullptr);
if ((flags_ & RECV) != 0) {
this->print_request("New recv");
- simgrid::smpi::Process* process = smpi_process_remote(simgrid::s4u::Actor::byPid(dst_));
+ simgrid::smpi::Process* process = smpi_process_remote(simgrid::s4u::Actor::by_pid(dst_));
int async_small_thresh = xbt_cfg_get_int("smpi/async-small-thresh");
// we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
real_size_=size_;
action_ = simcall_comm_irecv(
- process->process()->getImpl(), mailbox, buf_, &real_size_, &match_recv,
+ process->process()->get_impl(), mailbox, buf_, &real_size_, &match_recv,
process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this, -1.0);
XBT_DEBUG("recv simcall posted");
if (async_small_thresh != 0 || (flags_ & RMA) != 0 )
xbt_mutex_release(mut);
} else { /* the RECV flag was not set, so this is a send */
- simgrid::smpi::Process* process = smpi_process_remote(simgrid::s4u::Actor::byPid(dst_));
+ simgrid::smpi::Process* process = smpi_process_remote(simgrid::s4u::Actor::by_pid(dst_));
int rank = src_;
if (TRACE_smpi_view_internals()) {
TRACE_smpi_send(rank, rank, dst_, tag_, size_);
(static_cast<char*>(buf_) >= smpi_data_exe_start) &&
(static_cast<char*>(buf_) < smpi_data_exe_start + smpi_data_exe_size)) {
XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment ");
- smpi_switch_data_segment(simgrid::s4u::Actor::byPid(src_));
+ smpi_switch_data_segment(simgrid::s4u::Actor::by_pid(src_));
}
buf = xbt_malloc(size_);
memcpy(buf,oldbuf,size_);
// we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
real_size_=size_;
action_ = simcall_comm_isend(
- simgrid::s4u::Actor::byPid(src_)->getImpl(), mailbox, size_, -1.0, buf, real_size_, &match_send,
+ simgrid::s4u::Actor::by_pid(src_)->get_impl(), mailbox, size_, -1.0, buf, real_size_, &match_send,
&xbt_free_f, // how to free the userdata if a detached send fails
not process->replaying() ? smpi_comm_copy_data_callback : &smpi_comm_null_copy_buffer_callback, this,
// detach if msg size < eager/rdv switch limit
if (smpi_iprobe_sleep > 0) {
smx_activity_t iprobe_sleep = simcall_execution_start(
"iprobe", /* flops to executek*/ nsleeps * smpi_iprobe_sleep * speed * maxrate, /* priority */ 1.0,
- /* performance bound */ maxrate * speed, smpi_process()->process()->getImpl()->host);
+ /* performance bound */ maxrate * speed, smpi_process()->process()->get_impl()->host);
simcall_execution_wait(iprobe_sleep);
}
// behave like a receive, but don't do it
XBT_INFO("Suspend Actor (pid=%ld)", actor->get_pid());
actor->suspend();
- XBT_INFO("Actor (pid=%ld) is %ssuspended", actor->get_pid(), actor->isSuspended() ? "" : "not ");
+ XBT_INFO("Actor (pid=%ld) is %ssuspended", actor->get_pid(), actor->is_suspended() ? "" : "not ");
simgrid::s4u::this_actor::sleep_for(2);
XBT_INFO("Resume Actor (pid=%ld)", actor->get_pid());
actor->resume();
- XBT_INFO("Actor (pid=%ld) is %ssuspended", actor->get_pid(), actor->isSuspended() ? "" : "not ");
+ XBT_INFO("Actor (pid=%ld) is %ssuspended", actor->get_pid(), actor->is_suspended() ? "" : "not ");
simgrid::s4u::this_actor::sleep_for(2);
actor->kill();
for (int i = 0; i < 3; i++) {
int* pid = static_cast<int*>(mailbox->get());
XBT_INFO("Killing process \"%d\".", *pid);
- simgrid::s4u::Actor::byPid(*pid)->kill();
+ simgrid::s4u::Actor::by_pid(*pid)->kill();
}
}
simgrid::s4u::Engine e(&argc, argv);
e.loadPlatform(argv[1]);
- simgrid::s4u::Actor::killAll();
+ simgrid::s4u::Actor::kill_all();
simgrid::s4u::Actor::create("sendpid", simgrid::s4u::Host::by_name("Tremblay"), sendpid);
simgrid::s4u::Actor::create("sendpid", simgrid::s4u::Host::by_name("Tremblay"), sendpid);