Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use RAII for sthread_enable/disable.
[simgrid.git] / src / sthread / sthread_impl.cpp
index 4a92967..91c5c55 100644 (file)
@@ -80,11 +80,10 @@ int sthread_main(int argc, char** argv, char** envp, int (*raw_main)(int, char**
   zone->seal();
 
   /* Launch the user's main() on an actor */
-  sthread_enable();
+  const SThreadGuard sthread_guard;
   sg4::ActorPtr main_actor = sg4::Actor::create("main thread", lilibeth, raw_main, argc, argv, envp);
 
   sg4::Engine::get_instance()->run();
-  sthread_disable();
   XBT_INFO("All threads exited. Terminating the simulation.");
 
   return 0;
@@ -115,9 +114,8 @@ int sthread_create(unsigned long int* thread, const void* /*pthread_attr_t* attr
         if (SMPI_is_inited())
           SMPI_thread_create();
 #endif
-        sthread_enable();
+        const SThreadGuard sthread_guard;
         user_function(param);
-        sthread_disable();
       },
       start_routine, arg);