Our futures are based on the C++ Concurrency Technical Specification
API, with a few differences:
- - The simulation kernel is single-threaded so we do not need
+ - The simulation kernel is single-threaded so we do not need
inter-thread synchronization for our futures.
- As the simulation kernel cannot block, `f.wait()` is not meaningful
template<class T>
T simgrid::kernel::FutureState<T>::get()
{
- if (status_ != FutureStatus::ready)
- xbt_die("Deadlock: this future is not ready");
+ xbt_assert(status_ == FutureStatus::ready, "Deadlock: this future is not ready");
status_ = FutureStatus::done;
if (exception_) {
std::exception_ptr exception = std::move(exception_);
simulation kernel and yield the control until the request is
fulfilled. The performance requirements are very high because
the actors usually do an inordinate amount of simcalls during the
-simulation.
+simulation.
As for real syscalls, the basic idea is to write the wanted call and
its arguments in a memory area that is specific to the actor, and
@code{cpp}
struct s_smx_simcall {
// Simcall number:
- e_smx_simcall_t call;
+ Simcall call;
// Issuing actor:
smx_actor_t issuer;
// Arguments of the simcall:
@code{cpp}
xbt_dict_t Host::properties() {
return simgrid::simix::kernelImmediate([&] {
- simgrid::surf::HostImpl* surf_host =
- this->extension<simgrid::surf::HostImpl>();
- return surf_host->getProperties();
+ simgrid::kernel::resource::HostImpl* host =
+ this->extension<simgrid::kernel::resource::HostImpl>();
+ return host->getProperties();
});
}
@endcode
auto kernel_sync(F code) -> decltype(code().get())
{
typedef decltype(code().get()) T;
- if (SIMIX_is_maestro())
- xbt_die("Can't execute blocking call in kernel mode");
+ xbt_assert(not SIMIX_is_maestro(), "Can't execute blocking call in kernel mode");
- smx_actor_t self = SIMIX_process_self();
+ auto self = simgrid::kernel::actor::ActorImpl::self();
simgrid::xbt::Result<T> result;
simcall_run_blocking([&result, self, &code]{
{
if (!valid())
throw std::future_error(std::future_errc::no_state);
- smx_actor_t self = SIMIX_process_self();
+ auto self = simgrid::kernel::actor::ActorImpl::self();
simgrid::xbt::Result<T> result;
simcall_run_blocking([this, &result, self]{
try {
void notify_one();
void notify_all();
-
+
};
@endcode
double duration, P pred)
{
return this->wait_until(lock,
- SIMIX_get_clock() + duration, std::move(pred));
+ simgrid::s4u::Engine::get_clock() + duration, std::move(pred));
}
@endcode
In addition, we wrote variations of some other C++ standard library
classes (`SimulationClock`, `Mutex`, `ConditionVariable`) which work in
the simulation:
-
+
* using simulated time;
* using simcalls for synchronisation.
@endcode
-## Notes
+## Notes
[^getcompared]: