#include <string>
#include <unordered_map>
-XBT_PUBLIC void simcall_run_kernel(std::function<void()> const& code,
- simgrid::kernel::actor::SimcallObserver* observer);
+XBT_PUBLIC void simcall_run_answered(std::function<void()> const& code,
+ simgrid::kernel::actor::SimcallObserver* observer);
XBT_PUBLIC void simcall_run_blocking(std::function<void()> const& code,
simgrid::kernel::actor::SimcallObserver* observer);
* you may need to wait for that mutex to be unlocked by its current owner.
* Potentially blocking simcall must be issued using simcall_blocking(), right below in this file.
*/
-template <class F> typename std::result_of_t<F()> simcall(F&& code, SimcallObserver* observer = nullptr)
+template <class F> typename std::result_of_t<F()> simcall_answered(F&& code, SimcallObserver* observer = nullptr)
{
// If we are in the maestro, we take the fast path and execute the
// code directly without simcall marshalling/unmarshalling/dispatch:
// conveniently handles the success/failure value for us.
using R = typename std::result_of_t<F()>;
simgrid::xbt::Result<R> result;
- simcall_run_kernel([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward<F>(code)); }, observer);
+ simcall_run_answered([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward<F>(code)); }, observer);
return result.get();
}
cleanup_from_simix();
context_->set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
- actor::simcall([this] { s4u::Actor::on_termination(*get_ciface()); });
+ actor::simcall_answered([this] { s4u::Actor::on_termination(*get_ciface()); });
context_->set_wannadie();
}
return prng.uniform_int(min, max);
}
simgrid::kernel::actor::RandomSimcall observer{simgrid::kernel::actor::ActorImpl::self(), min, max};
- return simgrid::kernel::actor::simcall([&observer] { return observer.get_value(); }, &observer);
+ return simgrid::kernel::actor::simcall_answered([&observer] { return observer.get_value(); }, &observer);
}
namespace simgrid {
File::File(const std::string& fullpath, const_sg_host_t host, void* userdata) : fullpath_(fullpath)
{
- kernel::actor::simcall([this, &host, userdata] {
+ kernel::actor::simcall_answered([this, &host, userdata] {
this->set_data(userdata);
// this cannot fail because we get a xbt_die if the mountpoint does not exist
local_disk_ = find_local_disk_on(host);
{
std::vector<int>* desc_table =
Host::current()->extension<simgrid::s4u::FileDescriptorHostExt>()->file_descriptor_table.get();
- kernel::actor::simcall([this, desc_table] { desc_table->push_back(this->desc_id); });
+ kernel::actor::simcall_answered([this, desc_table] { desc_table->push_back(this->desc_id); });
}
File* File::open(const std::string& fullpath, void* userdata)
if (current_position_ > size_)
size_ = current_position_;
}
- kernel::actor::simcall([this] {
+ kernel::actor::simcall_answered([this] {
std::map<std::string, sg_size_t, std::less<>>* content = local_disk_->extension<FileSystemDiskExt>()->get_content();
content->erase(path_);
void FileSystemDiskExt::decr_used_size(sg_size_t size)
{
- simgrid::kernel::actor::simcall([this, size] { used_size_ -= size; });
+ simgrid::kernel::actor::simcall_answered([this, size] { used_size_ -= size; });
}
void FileSystemDiskExt::incr_used_size(sg_size_t size)
{
- simgrid::kernel::actor::simcall([this, size] { used_size_ += size; });
+ simgrid::kernel::actor::simcall_answered([this, size] { used_size_ += size; });
}
}
}
double HostEnergy::get_consumed_energy()
{
if (last_updated_ < simgrid::s4u::Engine::get_clock()) // We need to simcall this as it modifies the environment
- simgrid::kernel::actor::simcall(std::bind(&HostEnergy::update, this));
+ simgrid::kernel::actor::simcall_answered(std::bind(&HostEnergy::update, this));
return total_energy_;
}
*/
void sg_host_energy_update_all()
{
- simgrid::kernel::actor::simcall([]() {
+ simgrid::kernel::actor::simcall_answered([]() {
std::vector<simgrid::s4u::Host*> list = simgrid::s4u::Engine::get_instance()->get_all_hosts();
for (auto const& host : list)
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(host) == nullptr) { // Ignore virtual machines
double LinkEnergy::get_consumed_energy()
{
if (last_updated_ < simgrid::s4u::Engine::get_clock()) // We need to simcall this as it modifies the environment
- kernel::actor::simcall(std::bind(&LinkEnergy::update, this));
+ kernel::actor::simcall_answered(std::bind(&LinkEnergy::update, this));
return this->total_energy_;
}
} // namespace plugin
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::ActivityTestSimcall observer{issuer, pimpl_.get()};
- if (kernel::actor::simcall([&observer] { return observer.get_activity()->test(observer.get_issuer()); }, &observer)) {
+ if (kernel::actor::simcall_answered([&observer] { return observer.get_activity()->test(observer.get_issuer()); },
+ &observer)) {
complete(State::FINISHED);
return true;
}
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::ActivityTestanySimcall observer{issuer, ractivities};
- ssize_t changed_pos = kernel::actor::simcall(
+ ssize_t changed_pos = kernel::actor::simcall_answered(
[&observer] {
return kernel::activity::ActivityImpl::test_any(observer.get_issuer(), observer.get_activities());
},
Activity* Activity::cancel()
{
- kernel::actor::simcall([this] {
+ kernel::actor::simcall_answered([this] {
XBT_HERE();
if (pimpl_)
pimpl_->cancel();
{
const kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
kernel::actor::ActorImpl* actor =
- kernel::actor::simcall([self, &name, host] { return self->init(name, host).get(); });
+ kernel::actor::simcall_answered([self, &name, host] { return self->init(name, host).get(); });
return actor->get_iface();
}
ActorPtr Actor::start(const std::function<void()>& code)
{
- simgrid::kernel::actor::simcall([this, &code] { pimpl_->start(code); });
+ simgrid::kernel::actor::simcall_answered([this, &code] { pimpl_->start(code); });
return this;
}
{
const kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
kernel::actor::ActorImpl* actor =
- kernel::actor::simcall([self, &name, host, &code] { return self->init(name, host)->start(code); });
+ kernel::actor::simcall_answered([self, &name, host, &code] { return self->init(name, host)->start(code); });
return actor->get_iface();
}
Actor* Actor::set_auto_restart(bool autorestart)
{
- kernel::actor::simcall([this, autorestart]() {
+ kernel::actor::simcall_answered([this, autorestart]() {
xbt_assert(autorestart && not pimpl_->has_to_auto_restart()); // FIXME: handle all cases
pimpl_->set_auto_restart(autorestart);
void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun) const
{
- kernel::actor::simcall([this, &fun] { pimpl_->on_exit->emplace_back(fun); });
+ kernel::actor::simcall_answered([this, &fun] { pimpl_->on_exit->emplace_back(fun); });
}
void Actor::set_host(Host* new_host)
{
const s4u::Host* previous_location = get_host();
- kernel::actor::simcall([this, new_host]() {
+ kernel::actor::simcall_answered([this, new_host]() {
for (auto const& activity : pimpl_->activities_) {
// FIXME: implement the migration of other kinds of activities
if (auto exec = boost::dynamic_pointer_cast<kernel::activity::ExecImpl>(activity))
Actor* Actor::daemonize()
{
- kernel::actor::simcall([this]() { pimpl_->daemonize(); });
+ kernel::actor::simcall_answered([this]() { pimpl_->daemonize(); });
return this;
}
void Actor::resume()
{
- kernel::actor::simcall([this] { pimpl_->resume(); });
+ kernel::actor::simcall_answered([this] { pimpl_->resume(); });
s4u::Actor::on_resume(*this);
}
void Actor::set_kill_time(double kill_time)
{
- kernel::actor::simcall([this, kill_time] { pimpl_->set_kill_time(kill_time); });
+ kernel::actor::simcall_answered([this, kill_time] { pimpl_->set_kill_time(kill_time); });
}
/** @brief Get the kill time of an actor(or 0 if unset). */
void Actor::kill()
{
const kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
- kernel::actor::simcall([this, self] { self->kill(pimpl_); });
+ kernel::actor::simcall_answered([this, self] { self->kill(pimpl_); });
}
// ***** Static functions *****
void Actor::kill_all()
{
const kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
- kernel::actor::simcall([self] { self->kill_all(); });
+ kernel::actor::simcall_answered([self] { self->kill_all(); });
}
const std::unordered_map<std::string, std::string>* Actor::get_properties() const
void Actor::set_property(const std::string& key, const std::string& value)
{
- kernel::actor::simcall([this, &key, &value] { pimpl_->set_property(key, value); });
+ kernel::actor::simcall_answered([this, &key, &value] { pimpl_->set_property(key, value); });
}
Actor* Actor::restart()
{
- return kernel::actor::simcall([this]() { return pimpl_->restart(); });
+ return kernel::actor::simcall_answered([this]() { return pimpl_->restart(); });
}
// ***** this_actor *****
void yield()
{
- kernel::actor::simcall([] { /* do nothing*/ });
+ kernel::actor::simcall_answered([] { /* do nothing*/ });
}
XBT_PUBLIC void sleep_until(double wakeup_time)
void exit()
{
kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
- simgrid::kernel::actor::simcall([self] { self->exit(); });
+ simgrid::kernel::actor::simcall_answered([self] { self->exit(); });
THROW_IMPOSSIBLE;
}
xbt_assert(from_ != nullptr && to_ != nullptr, "When either from_ or to_ is specified, both must be.");
xbt_assert(src_buff_ == nullptr && dst_buff_ == nullptr,
"Direct host-to-host communications cannot carry any data.");
- pimpl_ = kernel::actor::simcall([this] {
+ pimpl_ = kernel::actor::simcall_answered([this] {
kernel::activity::CommImplPtr res(new kernel::activity::CommImpl(this->from_, this->to_, this->get_remaining()));
res->start();
return res;
copy_data_function_,
get_data<void>(),
detached_};
- pimpl_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::isend(&observer); }, &observer);
+ pimpl_ = kernel::actor::simcall_answered([&observer] { return kernel::activity::CommImpl::isend(&observer); },
+ &observer);
} else if (dst_buff_ != nullptr) { // Receiver side
xbt_assert(not detached_, "Receive cannot be detached");
on_recv(*this);
copy_data_function_,
get_data<void>(),
rate_};
- pimpl_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::irecv(&observer); }, &observer);
+ pimpl_ = kernel::actor::simcall_answered([&observer] { return kernel::activity::CommImpl::irecv(&observer); },
+ &observer);
} else {
xbt_die("Cannot start a communication before specifying whether we are the sender or the receiver");
}
ConditionVariablePtr ConditionVariable::create()
{
kernel::activity::ConditionVariableImpl* cond =
- kernel::actor::simcall([] { return new kernel::activity::ConditionVariableImpl(); });
+ kernel::actor::simcall_answered([] { return new kernel::activity::ConditionVariableImpl(); });
return ConditionVariablePtr(cond->get_iface(), false);
}
*/
void ConditionVariable::notify_one()
{
- simgrid::kernel::actor::simcall([this]() { pimpl_->signal(); });
+ simgrid::kernel::actor::simcall_answered([this]() { pimpl_->signal(); });
}
void ConditionVariable::notify_all()
{
- simgrid::kernel::actor::simcall([this]() { pimpl_->broadcast(); });
+ simgrid::kernel::actor::simcall_answered([this]() { pimpl_->broadcast(); });
}
void intrusive_ptr_add_ref(const ConditionVariable* cond)
Disk* Disk::set_read_bandwidth(double read_bw)
{
- kernel::actor::simcall([this, read_bw] { pimpl_->set_read_bandwidth(read_bw); });
+ kernel::actor::simcall_answered([this, read_bw] { pimpl_->set_read_bandwidth(read_bw); });
return this;
}
Disk* Disk::set_write_bandwidth(double write_bw)
{
- kernel::actor::simcall([this, write_bw] { pimpl_->set_write_bandwidth(write_bw); });
+ kernel::actor::simcall_answered([this, write_bw] { pimpl_->set_write_bandwidth(write_bw); });
return this;
}
Disk* Disk::set_readwrite_bandwidth(double bw)
{
- kernel::actor::simcall([this, bw] { pimpl_->set_readwrite_bandwidth(bw); });
+ kernel::actor::simcall_answered([this, bw] { pimpl_->set_readwrite_bandwidth(bw); });
return this;
}
Disk* Disk::set_property(const std::string& key, const std::string& value)
{
- kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+ kernel::actor::simcall_answered([this, &key, &value] { this->pimpl_->set_property(key, value); });
return this;
}
Disk* Disk::set_properties(const std::unordered_map<std::string, std::string>& properties)
{
- kernel::actor::simcall([this, properties] { this->pimpl_->set_properties(properties); });
+ kernel::actor::simcall_answered([this, properties] { this->pimpl_->set_properties(properties); });
return this;
}
Disk* Disk::set_state_profile(kernel::profile::Profile* profile)
{
xbt_assert(not pimpl_->is_sealed(), "Cannot set a state profile once the Disk is sealed");
- kernel::actor::simcall([this, profile]() { this->pimpl_->set_state_profile(profile); });
+ kernel::actor::simcall_answered([this, profile]() { this->pimpl_->set_state_profile(profile); });
return this;
}
Disk* Disk::set_read_bandwidth_profile(kernel::profile::Profile* profile)
{
xbt_assert(not pimpl_->is_sealed(), "Cannot set a bandwidth profile once the Disk is sealed");
- kernel::actor::simcall([this, profile]() { this->pimpl_->set_read_bandwidth_profile(profile); });
+ kernel::actor::simcall_answered([this, profile]() { this->pimpl_->set_read_bandwidth_profile(profile); });
return this;
}
Disk* Disk::set_write_bandwidth_profile(kernel::profile::Profile* profile)
{
xbt_assert(not pimpl_->is_sealed(), "Cannot set a bandwidth profile once the Disk is sealed");
- kernel::actor::simcall([this, profile]() { this->pimpl_->set_write_bandwidth_profile(profile); });
+ kernel::actor::simcall_answered([this, profile]() { this->pimpl_->set_write_bandwidth_profile(profile); });
return this;
}
Disk* Disk::set_sharing_policy(Disk::Operation op, Disk::SharingPolicy policy, const NonLinearResourceCb& cb)
{
- kernel::actor::simcall([this, op, policy, &cb] { pimpl_->set_sharing_policy(op, policy, cb); });
+ kernel::actor::simcall_answered([this, op, policy, &cb] { pimpl_->set_sharing_policy(op, policy, cb); });
return this;
}
Disk* Disk::set_factor_cb(const std::function<IoFactorCb>& cb)
{
- kernel::actor::simcall([this, &cb] { pimpl_->set_factor_cb(cb); });
+ kernel::actor::simcall_answered([this, &cb] { pimpl_->set_factor_cb(cb); });
return this;
}
Disk* Disk::seal()
{
- kernel::actor::simcall([this]{ pimpl_->seal(); });
+ kernel::actor::simcall_answered([this] { pimpl_->seal(); });
Disk::on_creation(*this); // notify the signal
return this;
}
void Engine::add_model(std::shared_ptr<kernel::resource::Model> model,
const std::vector<kernel::resource::Model*>& dependencies)
{
- kernel::actor::simcall([this, &model, &dependencies] { pimpl->add_model(std::move(model), dependencies); });
+ kernel::actor::simcall_answered([this, &model, &dependencies] { pimpl->add_model(std::move(model), dependencies); });
}
const std::vector<simgrid::kernel::resource::Model*>& Engine::get_all_models() const
}
void Engine::register_default(const kernel::actor::ActorCodeFactory& code)
{
- simgrid::kernel::actor::simcall([this, &code]() { pimpl->register_default(code); });
+ simgrid::kernel::actor::simcall_answered([this, &code]() { pimpl->register_default(code); });
}
void Engine::register_function(const std::string& name, const kernel::actor::ActorCodeFactory& code)
{
- simgrid::kernel::actor::simcall([this, name, &code]() { pimpl->register_function(name, code); });
+ simgrid::kernel::actor::simcall_answered([this, name, &code]() { pimpl->register_function(name, code); });
}
/** Load a deployment file and launch the actors that it contains
Mailbox* Engine::mailbox_by_name_or_create(const std::string& name) const
{
/* two actors may have pushed the same mbox_create simcall at the same time */
- kernel::activity::MailboxImpl* mbox = kernel::actor::simcall([&name, this] {
+ kernel::activity::MailboxImpl* mbox = kernel::actor::simcall_answered([&name, this] {
auto m = pimpl->mailboxes_.emplace(name, nullptr);
if (m.second) {
m.first->second = new kernel::activity::MailboxImpl(name);
/** @brief Register a new netpoint to the system */
void Engine::netpoint_register(kernel::routing::NetPoint* point)
{
- simgrid::kernel::actor::simcall([this, point] { pimpl->netpoints_[point->get_name()] = point; });
+ simgrid::kernel::actor::simcall_answered([this, point] { pimpl->netpoints_[point->get_name()] = point; });
}
/** @brief Unregister a given netpoint */
void Engine::netpoint_unregister(kernel::routing::NetPoint* point)
{
- kernel::actor::simcall([this, point] {
+ kernel::actor::simcall_answered([this, point] {
pimpl->netpoints_.erase(point->get_name());
delete point;
});
Exec* Exec::start()
{
- kernel::actor::simcall([this] {
+ kernel::actor::simcall_answered([this] {
(*boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_))
.set_name(get_name())
.set_tracing_category(get_tracing_category())
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING,
"Cannot change the bound of an exec after its start");
- kernel::actor::simcall(
+ kernel::actor::simcall_answered(
[this, bound] { boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_bound(bound); });
return this;
}
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING,
"Cannot change the priority of an exec after its start");
- kernel::actor::simcall([this, priority] {
+ kernel::actor::simcall_answered([this, priority] {
boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_sharing_penalty(1. / priority);
});
return this;
ExecPtr Exec::update_priority(double priority)
{
- kernel::actor::simcall([this, priority] {
+ kernel::actor::simcall_answered([this, priority] {
boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->update_sharing_penalty(1. / priority);
});
return this;
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING,
"Cannot change the flop_amount of an exec after its start");
- kernel::actor::simcall([this, flops_amount] {
+ kernel::actor::simcall_answered([this, flops_amount] {
boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_flops_amount(flops_amount);
});
Activity::set_remaining(flops_amount);
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING,
"Cannot change the flops_amounts of an exec after its start");
- kernel::actor::simcall([this, flops_amounts] {
+ kernel::actor::simcall_answered([this, flops_amounts] {
boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_flops_amounts(flops_amounts);
});
parallel_ = true;
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING,
"Cannot change the bytes_amounts of an exec after its start");
- kernel::actor::simcall([this, bytes_amounts] {
+ kernel::actor::simcall_answered([this, bytes_amounts] {
boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_bytes_amounts(bytes_amounts);
});
parallel_ = true;
if (state_ == State::STARTED)
boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->migrate(host);
- kernel::actor::simcall(
+ kernel::actor::simcall_answered(
[this, host] { boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_host(host); });
if (state_ == State::STARTING)
xbt_assert(state_ == State::INITED || state_ == State::STARTING,
"Cannot change the hosts of an exec once it's done (state: %s)", to_c_str(state_));
- kernel::actor::simcall(
+ kernel::actor::simcall_answered(
[this, hosts] { boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_hosts(hosts); });
parallel_ = true;
XBT_WARN("Calling get_remaining() on a parallel execution is not allowed. Call get_remaining_ratio() instead.");
return get_remaining_ratio();
} else
- return kernel::actor::simcall(
+ return kernel::actor::simcall_answered(
[this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_remaining(); });
}
double Exec::get_remaining_ratio() const
{
if (is_parallel())
- return kernel::actor::simcall(
+ return kernel::actor::simcall_answered(
[this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_par_remaining_ratio(); });
else
- return kernel::actor::simcall(
+ return kernel::actor::simcall_answered(
[this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_seq_remaining_ratio(); });
}
*/
void Host::destroy()
{
- kernel::actor::simcall([this] { this->pimpl_->destroy(); });
+ kernel::actor::simcall_answered([this] { this->pimpl_->destroy(); });
}
Host* Host::by_name(const std::string& name)
void Host::turn_on()
{
if (not is_on()) {
- kernel::actor::simcall([this] {
+ kernel::actor::simcall_answered([this] {
this->pimpl_cpu_->turn_on();
this->pimpl_->turn_on();
on_state_change(*this);
{
if (is_on()) {
const kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
- kernel::actor::simcall([this, self] {
+ kernel::actor::simcall_answered([this, self] {
for (VirtualMachine* const& vm : kernel::resource::VirtualMachineImpl::allVms_)
if (vm->get_pm() == this) {
vm->shutdown();
Host* Host::set_property(const std::string& key, const std::string& value)
{
- kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+ kernel::actor::simcall_answered([this, &key, &value] { this->pimpl_->set_property(key, value); });
return this;
}
Host* Host::set_properties(const std::unordered_map<std::string, std::string>& properties)
{
- kernel::actor::simcall([this, &properties] { this->pimpl_->set_properties(properties); });
+ kernel::actor::simcall_answered([this, &properties] { this->pimpl_->set_properties(properties); });
return this;
}
* The profile must contain boolean values. */
Host* Host::set_state_profile(kernel::profile::Profile* p)
{
- kernel::actor::simcall([this, p] { pimpl_cpu_->set_state_profile(p); });
+ kernel::actor::simcall_answered([this, p] { pimpl_cpu_->set_state_profile(p); });
return this;
}
/** Specify a profile modeling the external load according to an exhaustive list or a stochastic law.
*/
Host* Host::set_speed_profile(kernel::profile::Profile* p)
{
- kernel::actor::simcall([this, p] { pimpl_cpu_->set_speed_profile(p); });
+ kernel::actor::simcall_answered([this, p] { pimpl_cpu_->set_speed_profile(p); });
return this;
}
Host* Host::set_sharing_policy(SharingPolicy policy, const s4u::NonLinearResourceCb& cb)
{
- kernel::actor::simcall([this, policy, &cb] { pimpl_cpu_->set_sharing_policy(policy, cb); });
+ kernel::actor::simcall_answered([this, policy, &cb] { pimpl_cpu_->set_sharing_policy(policy, cb); });
return this;
}
Host* Host::set_core_count(int core_count)
{
- kernel::actor::simcall([this, core_count] { this->pimpl_cpu_->set_core_count(core_count); });
+ kernel::actor::simcall_answered([this, core_count] { this->pimpl_cpu_->set_core_count(core_count); });
return this;
}
Host* Host::set_pstate_speed(const std::vector<double>& speed_per_state)
{
- kernel::actor::simcall([this, &speed_per_state] { pimpl_cpu_->set_pstate_speed(speed_per_state); });
+ kernel::actor::simcall_answered([this, &speed_per_state] { pimpl_cpu_->set_pstate_speed(speed_per_state); });
return this;
}
/** @brief Set the pstate at which the host should run */
Host* Host::set_pstate(unsigned long pstate_index)
{
- kernel::actor::simcall([this, pstate_index] { this->pimpl_cpu_->set_pstate(pstate_index); });
+ kernel::actor::simcall_answered([this, pstate_index] { this->pimpl_cpu_->set_pstate(pstate_index); });
return this;
}
Host* Host::set_factor_cb(const std::function<CpuFactorCb>& cb)
{
- kernel::actor::simcall([this, &cb] { pimpl_cpu_->set_factor_cb(cb); });
+ kernel::actor::simcall_answered([this, &cb] { pimpl_cpu_->set_factor_cb(cb); });
return this;
}
Host* Host::set_coordinates(const std::string& coords)
{
if (not coords.empty())
- kernel::actor::simcall([this, coords] { this->pimpl_netpoint_->set_coordinates(coords); });
+ kernel::actor::simcall_answered([this, coords] { this->pimpl_netpoint_->set_coordinates(coords); });
return this;
}
std::vector<Disk*> Host::get_disks() const
Disk* Host::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
{
- return kernel::actor::simcall([this, &name, read_bandwidth, write_bandwidth] {
+ return kernel::actor::simcall_answered([this, &name, read_bandwidth, write_bandwidth] {
auto* disk = pimpl_->create_disk(name, read_bandwidth, write_bandwidth);
pimpl_->add_disk(disk);
return disk;
void Host::add_disk(const Disk* disk)
{
- kernel::actor::simcall([this, disk] { this->pimpl_->add_disk(disk); });
+ kernel::actor::simcall_answered([this, disk] { this->pimpl_->add_disk(disk); });
}
void Host::remove_disk(const std::string& disk_name)
{
- kernel::actor::simcall([this, disk_name] { this->pimpl_->remove_disk(disk_name); });
+ kernel::actor::simcall_answered([this, disk_name] { this->pimpl_->remove_disk(disk_name); });
}
VirtualMachine* Host::create_vm(const std::string& name, int core_amount)
Host* Host::seal()
{
- kernel::actor::simcall([this]() { this->pimpl_->seal(); });
+ kernel::actor::simcall_answered([this]() { this->pimpl_->seal(); });
simgrid::s4u::Host::on_creation(*this); // notify the signal
return this;
}
Io* Io::start()
{
- kernel::actor::simcall(
+ kernel::actor::simcall_answered(
[this] { (*boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)).set_name(get_name()).start(); });
if (suspended_)
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING, "Cannot set disk once the Io is started");
- kernel::actor::simcall(
+ kernel::actor::simcall_answered(
[this, disk] { boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->set_disk(disk->get_impl()); });
// Setting the disk may allow to start the activity, let's try
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING,
"Cannot change the priority of an io after its start");
- kernel::actor::simcall([this, priority] {
+ kernel::actor::simcall_answered([this, priority] {
boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->set_sharing_penalty(1. / priority);
});
return this;
IoPtr Io::set_size(sg_size_t size)
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING, "Cannot set size once the Io is started");
- kernel::actor::simcall(
+ kernel::actor::simcall_answered(
[this, size] { boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->set_size(size); });
Activity::set_remaining(size);
return this;
IoPtr Io::set_op_type(OpType type)
{
xbt_assert(state_ == State::INITED || state_ == State::STARTING, "Cannot set size once the Io is started");
- kernel::actor::simcall(
+ kernel::actor::simcall_answered(
[this, type] { boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->set_type(type); });
return this;
}
IoPtr Io::update_priority(double priority)
{
- kernel::actor::simcall([this, priority] {
+ kernel::actor::simcall_answered([this, priority] {
boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->update_sharing_penalty(1. / priority);
});
return this;
/** @brief Returns the amount of flops that remain to be done */
double Io::get_remaining() const
{
- return kernel::actor::simcall(
+ return kernel::actor::simcall_answered(
[this]() { return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_remaining(); });
}
Link* Link::set_latency(double value)
{
- kernel::actor::simcall([this, value] { pimpl_->set_latency(value); });
+ kernel::actor::simcall_answered([this, value] { pimpl_->set_latency(value); });
return this;
}
Link* Link::set_bandwidth(double value)
{
- kernel::actor::simcall([this, value] { pimpl_->set_bandwidth(value); });
+ kernel::actor::simcall_answered([this, value] { pimpl_->set_bandwidth(value); });
return this;
}
throw std::invalid_argument(std::string("Impossible to set wifi or split-duplex for the link: ") + get_name() +
std::string(". Use appropriate create function in NetZone."));
- kernel::actor::simcall([this, policy, &cb] { pimpl_->set_sharing_policy(policy, cb); });
+ kernel::actor::simcall_answered([this, policy, &cb] { pimpl_->set_sharing_policy(policy, cb); });
return this;
}
Link::SharingPolicy Link::get_sharing_policy() const
Link* Link::set_concurrency_limit(int limit)
{
- kernel::actor::simcall([this, limit] { pimpl_->set_concurrency_limit(limit); });
+ kernel::actor::simcall_answered([this, limit] { pimpl_->set_concurrency_limit(limit); });
return this;
}
void Link::turn_on()
{
- kernel::actor::simcall([this]() { this->pimpl_->turn_on(); });
+ kernel::actor::simcall_answered([this]() { this->pimpl_->turn_on(); });
}
void Link::turn_off()
{
- kernel::actor::simcall([this]() { this->pimpl_->turn_off(); });
+ kernel::actor::simcall_answered([this]() { this->pimpl_->turn_off(); });
}
Link* Link::seal()
{
- kernel::actor::simcall([this]() { this->pimpl_->seal(); });
+ kernel::actor::simcall_answered([this]() { this->pimpl_->seal(); });
s4u::Link::on_creation(*this); // notify the signal
return this;
}
Link* Link::set_state_profile(kernel::profile::Profile* profile)
{
xbt_assert(not pimpl_->is_sealed(), "Cannot set a state profile once the Link is sealed");
- kernel::actor::simcall([this, profile]() { this->pimpl_->set_state_profile(profile); });
+ kernel::actor::simcall_answered([this, profile]() { this->pimpl_->set_state_profile(profile); });
return this;
}
Link* Link::set_bandwidth_profile(kernel::profile::Profile* profile)
{
xbt_assert(not pimpl_->is_sealed(), "Cannot set a bandwidth profile once the Link is sealed");
- kernel::actor::simcall([this, profile]() { this->pimpl_->set_bandwidth_profile(profile); });
+ kernel::actor::simcall_answered([this, profile]() { this->pimpl_->set_bandwidth_profile(profile); });
return this;
}
Link* Link::set_latency_profile(kernel::profile::Profile* profile)
{
xbt_assert(not pimpl_->is_sealed(), "Cannot set a latency profile once the Link is sealed");
- kernel::actor::simcall([this, profile]() { this->pimpl_->set_latency_profile(profile); });
+ kernel::actor::simcall_answered([this, profile]() { this->pimpl_->set_latency_profile(profile); });
return this;
}
}
Link* Link::set_property(const std::string& key, const std::string& value)
{
- kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+ kernel::actor::simcall_answered([this, &key, &value] { this->pimpl_->set_property(key, value); });
return this;
}
Link* Link::set_properties(const std::unordered_map<std::string, std::string>& properties)
{
- kernel::actor::simcall([this, &properties] { this->pimpl_->set_properties(properties); });
+ kernel::actor::simcall_answered([this, &properties] { this->pimpl_->set_properties(properties); });
return this;
}
void Mailbox::set_receiver(ActorPtr actor)
{
- kernel::actor::simcall([this, actor]() { this->pimpl_->set_receiver(actor); });
+ kernel::actor::simcall_answered([this, actor]() { this->pimpl_->set_receiver(actor); });
}
/** @brief get the receiver (process associated to the mailbox) */
kernel::activity::ActivityImplPtr
Mailbox::iprobe(int type, bool (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data)
{
- return kernel::actor::simcall([this, type, match_fun, data] { return pimpl_->iprobe(type, match_fun, data); });
+ return kernel::actor::simcall_answered(
+ [this, type, match_fun, data] { return pimpl_->iprobe(type, match_fun, data); });
}
} // namespace s4u
} // namespace simgrid
if (MC_is_active() || MC_record_replay_is_active()) { // Split in 2 simcalls for transition persistency
kernel::actor::MutexObserver lock_observer{issuer, mc::Transition::Type::MUTEX_LOCK, pimpl_};
- auto acquisition = kernel::actor::simcall([issuer, this] { return pimpl_->lock_async(issuer); }, &lock_observer);
+ auto acquisition =
+ kernel::actor::simcall_answered([issuer, this] { return pimpl_->lock_async(issuer); }, &lock_observer);
kernel::actor::MutexObserver wait_observer{issuer, mc::Transition::Type::MUTEX_WAIT, pimpl_};
kernel::actor::simcall_blocking([issuer, acquisition] { return acquisition->wait_for(issuer, -1); },
{
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::MutexObserver observer{issuer, mc::Transition::Type::MUTEX_UNLOCK, pimpl_};
- kernel::actor::simcall([this, issuer] { this->pimpl_->unlock(issuer); }, &observer);
+ kernel::actor::simcall_answered([this, issuer] { this->pimpl_->unlock(issuer); }, &observer);
}
/** @brief Acquire the mutex if it's free, and return false (without blocking) if not */
{
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::MutexObserver observer{issuer, mc::Transition::Type::MUTEX_TRYLOCK, pimpl_};
- return kernel::actor::simcall([&observer] { return observer.get_mutex()->try_lock(observer.get_issuer()); },
- &observer);
+ return kernel::actor::simcall_answered([&observer] { return observer.get_mutex()->try_lock(observer.get_issuer()); },
+ &observer);
}
/** @brief Create a new mutex
void NetZone::set_property(const std::string& key, const std::string& value)
{
- kernel::actor::simcall([this, &key, &value] { pimpl_->set_property(key, value); });
+ kernel::actor::simcall_answered([this, &key, &value] { pimpl_->set_property(key, value); });
}
/** @brief Returns the list of direct children (no grand-children) */
NetZone* NetZone::set_parent(const NetZone* parent)
{
- kernel::actor::simcall([this, parent] { pimpl_->set_parent(parent->get_impl()); });
+ kernel::actor::simcall_answered([this, parent] { pimpl_->set_parent(parent->get_impl()); });
return this;
}
NetZone* NetZone::seal()
{
- kernel::actor::simcall([this] { pimpl_->seal(); });
+ kernel::actor::simcall_answered([this] { pimpl_->seal(); });
return this;
}
s4u::Host* NetZone::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
{
- return kernel::actor::simcall(
+ return kernel::actor::simcall_answered(
[this, &name, &speed_per_pstate] { return pimpl_->create_host(name, speed_per_pstate); });
}
s4u::Link* NetZone::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
- return kernel::actor::simcall([this, &name, &bandwidths] { return pimpl_->create_link(name, bandwidths); });
+ return kernel::actor::simcall_answered([this, &name, &bandwidths] { return pimpl_->create_link(name, bandwidths); });
}
s4u::Link* NetZone::create_link(const std::string& name, const std::string& bandwidth)
s4u::SplitDuplexLink* NetZone::create_split_duplex_link(const std::string& name, double bandwidth)
{
- return kernel::actor::simcall(
+ return kernel::actor::simcall_answered(
[this, &name, &bandwidth] { return pimpl_->create_split_duplex_link(name, std::vector<double>{bandwidth}); });
}
kernel::routing::NetPoint* NetZone::create_router(const std::string& name)
{
- return kernel::actor::simcall([this, &name] { return pimpl_->create_router(name); });
+ return kernel::actor::simcall_answered([this, &name] { return pimpl_->create_router(name); });
}
kernel::routing::NetPoint* NetZone::get_netpoint()
void Semaphore::release()
{
- kernel::actor::simcall([this] { pimpl_->release(); });
+ kernel::actor::simcall_answered([this] { pimpl_->release(); });
}
int Semaphore::get_capacity() const
{
- return kernel::actor::simcall([this] { return pimpl_->get_capacity(); });
+ return kernel::actor::simcall_answered([this] { return pimpl_->get_capacity(); });
}
bool Semaphore::would_block() const
{
- return kernel::actor::simcall([this] { return pimpl_->would_block(); });
+ return kernel::actor::simcall_answered([this] { return pimpl_->would_block(); });
}
/* refcounting of the intrusive_ptr is delegated to the implementation object */
VmHostExt::ensureVmExtInstalled();
- kernel::actor::simcall([this]() {
+ kernel::actor::simcall_answered([this]() {
Host* pm = this->pimpl_vm_->get_physical_host();
if (pm->extension<VmHostExt>() == nullptr)
pm->extension_set(new VmHostExt());
{
on_suspend(*this);
const kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
- kernel::actor::simcall([this, issuer]() { pimpl_vm_->suspend(issuer); });
+ kernel::actor::simcall_answered([this, issuer]() { pimpl_vm_->suspend(issuer); });
}
void VirtualMachine::resume()
void VirtualMachine::shutdown()
{
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
- kernel::actor::simcall([this, issuer]() { pimpl_vm_->shutdown(issuer); });
+ kernel::actor::simcall_answered([this, issuer]() { pimpl_vm_->shutdown(issuer); });
on_shutdown(*this);
}
XBT_DEBUG("destroy %s", get_cname());
on_destruction(*this);
/* Then, destroy the VM object */
- kernel::actor::simcall([this]() {
+ kernel::actor::simcall_answered([this]() {
get_vm_impl()->vm_destroy();
get_impl()->destroy();
VirtualMachine* VirtualMachine::set_pm(simgrid::s4u::Host* pm)
{
- kernel::actor::simcall([this, pm]() { pimpl_vm_->set_physical_host(pm); });
+ kernel::actor::simcall_answered([this, pm]() { pimpl_vm_->set_physical_host(pm); });
return this;
}
VirtualMachine::State VirtualMachine::get_state() const
{
- return kernel::actor::simcall([this]() { return pimpl_vm_->get_state(); });
+ return kernel::actor::simcall_answered([this]() { return pimpl_vm_->get_state(); });
}
size_t VirtualMachine::get_ramsize() const
*/
VirtualMachine* VirtualMachine::set_bound(double bound)
{
- kernel::actor::simcall([this, bound]() { pimpl_vm_->set_bound(bound); });
+ kernel::actor::simcall_answered([this, bound]() { pimpl_vm_->set_bound(bound); });
return this;
}
simgrid::kernel::actor::CommIsendSimcall send_observer{
sender, mbox, task_size, rate, static_cast<unsigned char*>(src_buff), src_buff_size, match_fun,
nullptr, copy_data_fun, data, false};
- comm = simgrid::kernel::actor::simcall(
+ comm = simgrid::kernel::actor::simcall_answered(
[&send_observer] { return simgrid::kernel::activity::CommImpl::isend(&send_observer); }, &send_observer);
simgrid::kernel::actor::ActivityWaitSimcall wait_observer{sender, comm.get(), timeout};
simgrid::kernel::actor::CommIsendSimcall observer(sender, mbox, task_size, rate,
static_cast<unsigned char*>(src_buff), src_buff_size, match_fun,
clean_fun, copy_data_fun, data, detached);
- return simgrid::kernel::actor::simcall([&observer] { return simgrid::kernel::activity::CommImpl::isend(&observer); });
+ return simgrid::kernel::actor::simcall_answered(
+ [&observer] { return simgrid::kernel::activity::CommImpl::isend(&observer); });
}
/**
simgrid::kernel::actor::CommIrecvSimcall observer{
receiver, mbox, static_cast<unsigned char*>(dst_buff), dst_buff_size, match_fun, copy_data_fun, data, rate};
- comm = simgrid::kernel::actor::simcall(
+ comm = simgrid::kernel::actor::simcall_answered(
[&observer] { return simgrid::kernel::activity::CommImpl::irecv(&observer); }, &observer);
simgrid::kernel::actor::ActivityWaitSimcall wait_observer{receiver, comm.get(), timeout};
simgrid::kernel::actor::CommIrecvSimcall observer(receiver, mbox, static_cast<unsigned char*>(dst_buff),
dst_buff_size, match_fun, copy_data_fun, data, rate);
- return simgrid::kernel::actor::simcall([&observer] { return simgrid::kernel::activity::CommImpl::irecv(&observer); });
+ return simgrid::kernel::actor::simcall_answered(
+ [&observer] { return simgrid::kernel::activity::CommImpl::irecv(&observer); });
}
/**
}
}
-void simcall_run_kernel(std::function<void()> const& code, simgrid::kernel::actor::SimcallObserver* observer)
+void simcall_run_answered(std::function<void()> const& code, simgrid::kernel::actor::SimcallObserver* observer)
{
simgrid::kernel::actor::ActorImpl::self()->simcall_.observer_ = observer;
// The function `code` is called in kernel mode (either because we are already in maestor or after a context switch)
for (int i = 0; i < comm->size(); i++){
auto actor = simgrid::kernel::actor::ActorImpl::by_pid(comm->group()->actor(i));
if (actor != nullptr && actor != myself)
- simgrid::kernel::actor::simcall([actor] { actor->exit(); });
+ simgrid::kernel::actor::simcall_answered([actor] { actor->exit(); });
}
// now ourself
- simgrid::kernel::actor::simcall([myself] { myself->exit(); });
+ simgrid::kernel::actor::simcall_answered([myself] { myself->exit(); });
return MPI_SUCCESS;
}
-1.0};
observer.set_tag(tag_);
- action_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::irecv(&observer); }, &observer);
+ action_ = kernel::actor::simcall_answered([&observer] { return kernel::activity::CommImpl::irecv(&observer); },
+ &observer);
XBT_DEBUG("recv simcall posted");
// detach if msg size < eager/rdv switch limit
detached_};
observer.set_tag(tag_);
- action_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::isend(&observer); }, &observer);
+ action_ = kernel::actor::simcall_answered([&observer] { return kernel::activity::CommImpl::isend(&observer); },
+ &observer);
XBT_DEBUG("send simcall posted");
/* FIXME: detached sends are not traceable (action_ == nullptr) */
try{
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::ActivityTestSimcall observer{issuer, (*request)->action_.get()};
- *flag = kernel::actor::simcall([&observer] { return observer.get_activity()->test(observer.get_issuer()); },
- &observer);
+ *flag = kernel::actor::simcall_answered(
+ [&observer] { return observer.get_activity()->test(observer.get_issuer()); }, &observer);
} catch (const Exception&) {
*flag = 0;
return ret;
try{
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::ActivityTestanySimcall observer{issuer, comms};
- i = kernel::actor::simcall(
+ i = kernel::actor::simcall_answered(
[&observer] {
return kernel::activity::ActivityImpl::test_any(observer.get_issuer(), observer.get_activities());
},
using T = decltype(code().get());
// Execute the code in the kernel and get the kernel future:
- kernel::Future<T> future = kernel::actor::simcall(std::move(code));
+ kernel::Future<T> future = kernel::actor::simcall_answered(std::move(code));
// Wrap the kernel future in an actor future:
return Future<T>(std::move(future));
{
// Test the simple immediate execution:
XBT_INFO("Start");
- simgrid::kernel::actor::simcall([] { XBT_INFO("kernel"); });
+ simgrid::kernel::actor::simcall_answered([] { XBT_INFO("kernel"); });
XBT_INFO("kernel, returned");
// Synchronize on a successful Future<void>: