Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Enable GLIBCXX_DEBUG in maintainer mode
[simgrid.git] / doc / doxygen / uhood_switch.doc
index 72a8605..98d55a9 100644 (file)
@@ -109,7 +109,7 @@ simulation kernel.
 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
@@ -260,8 +260,7 @@ T simgrid::kernel::Future::get()
 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_);
@@ -280,7 +279,7 @@ So a simcall is a way for the actor to push a request to the
 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
@@ -328,7 +327,7 @@ number and its arguments (among some other things):
 @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:
@@ -337,7 +336,6 @@ struct s_smx_simcall {
   union u_smx_scalar result;
   // Some additional stuff:
   smx_timer_t timer;
-  int mc_value;
 };
 @endcode
 
@@ -413,7 +411,7 @@ type and properly handles exceptions:
 
 @code{cpp}
 template<class F>
-typename std::result_of<F()>::type kernelImmediate(F&& code)
+typename std::result_of_t<F()> kernelImmediate(F&& code)
 {
   // If we are in the simulation kernel, we take the fast path and
   // execute the code directly without simcall
@@ -423,7 +421,7 @@ typename std::result_of<F()>::type kernelImmediate(F&& code)
 
   // If we are in the application, pass the code to the simulation
   // kernel which executes it for us and reports the result:
-  typedef typename std::result_of<F()>::type R;
+  typedef typename std::result_of_t<F()> R;
   simgrid::xbt::Result<R> result;
   simcall_run_kernel([&]{
     xbt_assert(SIMIX_is_maestro(), "Not in maestro");
@@ -440,9 +438,9 @@ Example of usage:
 @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
@@ -478,10 +476,9 @@ template<class F>
 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]{
@@ -551,7 +548,7 @@ T simgrid::simix::Future<T>::get()
 {
   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 {
@@ -678,7 +675,7 @@ public:
 
   void notify_one();
   void notify_all();
-  
+
 };
 @endcode
 
@@ -749,7 +746,7 @@ bool ConditionVariable::wait_for(std::unique_lock<Mutex>& lock,
   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
 
@@ -770,7 +767,7 @@ expose asynchronous operations in the simulation kernel to the actors.
 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.
@@ -789,7 +786,7 @@ Reusing the same API as the C++ standard library is very useful because:
 
 This type of approach might be useful for other libraries which define
 their own contexts. An example of this is
-[Mordor](https://github.com/mozy/mordor), a I/O library using fibers
+[Mordor](https://github.com/mozy/mordor), an I/O library using fibers
 (cooperative scheduling): it implements cooperative/fiber
 [mutex](https://github.com/mozy/mordor/blob/4803b6343aee531bfc3588ffc26a0d0fdf14b274/mordor/fibersynchronization.h#L70),
 [recursive
@@ -933,7 +930,7 @@ auto makeTask(F code, Args... args)
 @endcode
 
 
-## Notes    
+## Notes
 
 [^getcompared]: