namespace kernel {
namespace activity {
-ActivityImpl::ActivityImpl() = default;
-ActivityImpl::~ActivityImpl() = default;
-
// boost::intrusive_ptr<Activity> support:
void intrusive_ptr_add_ref(simgrid::kernel::activity::ActivityImpl* activity)
{
class XBT_PUBLIC ActivityImpl {
public:
- ActivityImpl();
+ ActivityImpl() = default;
explicit ActivityImpl(std::string name) : name_(name) {}
- virtual ~ActivityImpl();
+ explicit ActivityImpl(std::string name, resource::Action* surf_action) : name_(name), surf_action_(surf_action) {}
+ virtual ~ActivityImpl() = default;
e_smx_state_t state_ = SIMIX_WAITING; /* State of the activity */
std::string name_; /* Activity name if any */
std::list<smx_simcall_t> simcalls_; /* List of simcalls waiting for this activity */
+ resource::Action* surf_action_ = nullptr;
virtual void suspend() = 0;
virtual void resume() = 0;
simgrid::kernel::activity::ExecImpl::ExecImpl(std::string name, resource::Action* surf_action,
resource::Action* timeout_detector, s4u::Host* host)
- : ActivityImpl(name), host_(host), surf_action_(surf_action), timeout_detector_(timeout_detector)
+ : ActivityImpl(name, surf_action), host_(host), timeout_detector_(timeout_detector)
{
this->state_ = SIMIX_RUNNING;
/* The host where the execution takes place. nullptr means this is a parallel exec (and only surf knows the hosts) */
s4u::Host* host_ = nullptr;
- resource::Action* surf_action_; /* The Surf execution action encapsulated */
private:
resource::Action* timeout_detector_ = nullptr;
class XBT_PUBLIC IoImpl : public ActivityImpl {
public:
~IoImpl() override;
- explicit IoImpl(std::string name, simgrid::surf::StorageImpl* storage);
+ explicit IoImpl(std::string name, surf::StorageImpl* storage);
void start(sg_size_t size, simgrid::s4u::Io::OpType type);
void suspend() override;
double get_remaining();
sg_size_t get_performed_ioops() { return performed_ioops_; }
- simgrid::surf::StorageImpl* storage_ = nullptr;
- simgrid::kernel::resource::Action* surf_action_ = nullptr;
+ surf::StorageImpl* storage_ = nullptr;
sg_size_t performed_ioops_ = 0;
static simgrid::xbt::signal<void(kernel::activity::IoImplPtr)> on_start;
static simgrid::xbt::signal<void(kernel::activity::IoImplPtr)> on_completion;
void simgrid::kernel::activity::SleepImpl::suspend()
{
- surf_sleep->suspend();
+ surf_action_->suspend();
}
void simgrid::kernel::activity::SleepImpl::resume()
{
- surf_sleep->resume();
+ surf_action_->resume();
}
void simgrid::kernel::activity::SleepImpl::post()
std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed")));
}
- switch (surf_sleep->get_state()) {
+ switch (surf_action_->get_state()) {
case simgrid::kernel::resource::Action::State::FAILED:
simcall->issuer->context_->iwannadie = true;
result = SIMIX_FAILED;
void resume() override;
void post() override;
- sg_host_t host = nullptr; /* The host that is sleeping */
- simgrid::kernel::resource::Action* surf_sleep = nullptr; /* The Surf sleeping action encapsulated */
+ sg_host_t host = nullptr;
};
}
}
simgrid::kernel::activity::RawImpl::~RawImpl()
{
- sleep->unref();
+ surf_action_->unref();
}
void simgrid::kernel::activity::RawImpl::suspend()
{
void simgrid::kernel::activity::RawImpl::post()
{
XBT_IN("(%p)",this);
- if (sleep->get_state() == simgrid::kernel::resource::Action::State::FAILED)
+ if (surf_action_->get_state() == simgrid::kernel::resource::Action::State::FAILED)
state_ = SIMIX_FAILED;
- else if (sleep->get_state() == simgrid::kernel::resource::Action::State::FINISHED)
+ else if (surf_action_->get_state() == simgrid::kernel::resource::Action::State::FINISHED)
state_ = SIMIX_SRC_TIMEOUT;
SIMIX_synchro_finish(this);
void suspend() override;
void resume() override;
void post() override;
-
- simgrid::kernel::resource::Action* sleep = nullptr;
- };
-
+};
}}} // namespace simgrid::kernel::activity
#endif
simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl();
synchro->host = host_;
- synchro->surf_sleep = host_->pimpl_cpu->sleep(duration);
- synchro->surf_sleep->set_data(synchro);
+ synchro->surf_action_ = host_->pimpl_cpu->sleep(duration);
+ synchro->surf_action_->set_data(synchro);
XBT_DEBUG("Create sleep synchronization %p", synchro);
return synchro;
if (i != actor->waiting_synchro->simcalls_.end())
actor->waiting_synchro->simcalls_.remove(&actor->simcall);
} else if (sleep != nullptr) {
- if (sleep->surf_sleep)
- sleep->surf_sleep->cancel();
+ if (sleep->surf_action_)
+ sleep->surf_action_->cancel();
sleep->post();
} else if (raw != nullptr) {
SIMIX_synchro_stop_waiting(actor, &actor->simcall);
SIMIX_process_on_exit(process,
[](int, void* arg) {
auto sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(arg);
- if (sleep->surf_sleep)
- sleep->surf_sleep->finish(simgrid::kernel::resource::Action::State::FINISHED);
+ if (sleep->surf_action_)
+ sleep->surf_action_->finish(simgrid::kernel::resource::Action::State::FINISHED);
intrusive_ptr_release(sleep);
},
res.get());
simgrid::kernel::activity::SleepImplPtr sleep =
boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(synchro);
- if (sleep->surf_sleep) {
- sleep->surf_sleep->unref();
- sleep->surf_sleep = nullptr;
+ if (sleep->surf_action_) {
+ sleep->surf_action_->unref();
+ sleep->surf_action_ = nullptr;
}
}
simgrid::kernel::activity::RawImplPtr sync =
simgrid::kernel::activity::RawImplPtr(new simgrid::kernel::activity::RawImpl());
- sync->sleep = smx_host->pimpl_cpu->sleep(timeout);
- sync->sleep->set_data(sync.get());
+ sync->surf_action_ = smx_host->pimpl_cpu->sleep(timeout);
+ sync->surf_action_->set_data(sync.get());
XBT_OUT();
return sync;
}