#include "simgrid/s4u/Mailbox.hpp"
#include "src/kernel/context/Context.hpp"
-#include "src/simix/smx_private.h"
+#include "src/simix/smx_private.hpp"
#include <sstream>
}
void Actor::setAutoRestart(bool autorestart) {
- simcall_process_auto_restart_set(pimpl_,autorestart);
+ simgrid::simix::kernelImmediate([this, autorestart]() { pimpl_->auto_restart = autorestart; });
}
void Actor::onExit(int_f_pvoid_pvoid_t fun, void* data)
simgrid::simix::kernelImmediate([this, new_host]() { pimpl_->new_host = new_host; });
}
-s4u::Host* Actor::host()
+s4u::Host* Actor::getHost()
{
return this->pimpl_->host;
}
simgrid::simix::kernelImmediate([this]() { pimpl_->daemonize(); });
}
-const char* Actor::cname()
+const simgrid::xbt::string& Actor::getName() const
{
- return this->pimpl_->name.c_str();
+ return this->pimpl_->getName();
}
-simgrid::xbt::string Actor::name()
+const char* Actor::getCname() const
{
- return this->pimpl_->name;
+ return this->pimpl_->getCname();
}
-aid_t Actor::pid()
+aid_t Actor::getPid()
{
return this->pimpl_->pid;
}
-aid_t Actor::ppid()
+aid_t Actor::getPpid()
{
return this->pimpl_->ppid;
}
void Actor::resume()
{
- simcall_process_resume(pimpl_);
+ simgrid::simix::kernelImmediate([this] { pimpl_->resume(); });
}
int Actor::isSuspended()
{
- return simgrid::simix::kernelImmediate([this]() { return pimpl_->suspended; });
+ return simgrid::simix::kernelImmediate([this] { return pimpl_->suspended; });
}
void Actor::setKillTime(double time) {
simcall_process_set_kill_time(pimpl_,time);
}
-double Actor::killTime()
+/** \brief Get the kill time of an actor(or 0 if unset). */
+double Actor::getKillTime()
{
- return simcall_process_get_kill_time(pimpl_);
+ return SIMIX_timer_get_date(pimpl_->kill_timer);
}
void Actor::kill(aid_t pid)
{
smx_actor_t process = SIMIX_process_from_PID(pid);
if(process != nullptr) {
- simcall_process_kill(process);
+ simgrid::simix::kernelImmediate([process] { SIMIX_process_kill(process, process); });
} else {
std::ostringstream oss;
oss << "kill: ("<< pid <<") - No such process" << std::endl;
}
void Actor::kill() {
- simcall_process_kill(pimpl_);
+ smx_actor_t process = SIMIX_process_self();
+ simgrid::simix::kernelImmediate(
+ [this, process] { SIMIX_process_kill(pimpl_, (pimpl_ == simix_global->maestro_process) ? pimpl_ : process); });
}
// ***** Static functions *****
}
/** Retrieve the property value (or nullptr if not set) */
-const char* Actor::property(const char* key)
+const char* Actor::getProperty(const char* key)
{
- return (char*)xbt_dict_get_or_null(simcall_process_get_properties(pimpl_), key);
+ return simgrid::simix::kernelImmediate([this, key] { return pimpl_->getProperty(key); });
}
+
void Actor::setProperty(const char* key, const char* value)
{
- simgrid::simix::kernelImmediate([this, key, value] {
- xbt_dict_set(simcall_process_get_properties(pimpl_), key, (char*)value, (void_f_pvoid_t) nullptr);
- });
+ simgrid::simix::kernelImmediate([this, key, value] { pimpl_->setProperty(key, value); });
+}
+
+Actor* Actor::restart()
+{
+ return simgrid::simix::kernelImmediate([this]() { return pimpl_->restart(); });
}
// ***** this_actor *****
simcall_process_sleep(timeout - now);
}
-e_smx_state_t execute(double flops) {
+void execute(double flops)
+{
smx_activity_t s = simcall_execution_start(nullptr,flops,1.0/*priority*/,0./*bound*/);
- return simcall_execution_wait(s);
+ simcall_execution_wait(s);
}
-void* recv(MailboxPtr chan) {
- return chan->recv();
+void* recv(MailboxPtr chan) // deprecated
+{
+ return chan->get();
}
-void* recv(MailboxPtr chan, double timeout)
+void* recv(MailboxPtr chan, double timeout) // deprecated
{
- return chan->recv(timeout);
+ return chan->get(timeout);
}
-void send(MailboxPtr chan, void* payload, double simulatedSize)
+void send(MailboxPtr chan, void* payload, double simulatedSize) // deprecated
{
- chan->send(payload, simulatedSize);
+ chan->put(payload, simulatedSize);
}
-void send(MailboxPtr chan, void* payload, double simulatedSize, double timeout)
+void send(MailboxPtr chan, void* payload, double simulatedSize, double timeout) // deprecated
{
- chan->send(payload, simulatedSize, timeout);
+ chan->put(payload, simulatedSize, timeout);
}
-CommPtr isend(MailboxPtr chan, void* payload, double simulatedSize)
+CommPtr isend(MailboxPtr chan, void* payload, double simulatedSize) // deprecated
{
- return chan->send_async(payload, simulatedSize);
+ return chan->put_async(payload, simulatedSize);
}
-CommPtr irecv(MailboxPtr chan, void** data)
+CommPtr irecv(MailboxPtr chan, void** data) // deprecated
{
- return chan->recv_async(data);
+ return chan->get_async(data);
}
-aid_t pid()
+aid_t getPid()
{
return SIMIX_process_self()->pid;
}
-aid_t ppid()
+aid_t getPpid()
{
return SIMIX_process_self()->ppid;
}
-std::string name()
+std::string getName()
+{
+ return SIMIX_process_self()->getName();
+}
+
+const char* getCname()
{
- return SIMIX_process_self()->name;
+ return SIMIX_process_self()->getCname();
}
-Host* host()
+Host* getHost()
{
return SIMIX_process_self()->host;
}
void resume()
{
- simcall_process_resume(SIMIX_process_self());
+ smx_actor_t process = SIMIX_process_self();
+ simgrid::simix::kernelImmediate([process] { process->resume(); });
}
bool isSuspended()
void kill()
{
- simcall_process_kill(SIMIX_process_self());
+ smx_actor_t process = SIMIX_process_self();
+ simgrid::simix::kernelImmediate([process] { SIMIX_process_kill(process, process); });
}
void onExit(int_f_pvoid_pvoid_t fun, void* data)