From c6db937f4997df889c08d42b34c9f54a2165e6b6 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 23 Nov 2022 15:29:39 +0100 Subject: [PATCH] Replace static function by a lambda. --- src/sthread/sthread_impl.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sthread/sthread_impl.cpp b/src/sthread/sthread_impl.cpp index 5ec2a0435a..433f26a49a 100644 --- a/src/sthread/sthread_impl.cpp +++ b/src/sthread/sthread_impl.cpp @@ -61,17 +61,6 @@ struct sthread_mutex { s4u_Mutex* mutex; }; -static void thread_create_wrapper(void* (*user_function)(void*), void* param) -{ -#if HAVE_SMPI - if (SMPI_is_inited()) - SMPI_thread_create(); -#endif - sthread_enable(); - user_function(param); - sthread_disable(); -} - int sthread_create(unsigned long int* thread, const void* /*pthread_attr_t* attr*/, void* (*start_routine)(void*), void* arg) { @@ -84,7 +73,18 @@ int sthread_create(unsigned long int* thread, const void* /*pthread_attr_t* attr MPI_Comm_rank(MPI_COMM_WORLD, &rank); #endif std::string name = simgrid::xbt::string_printf("%d:%d", rank, TID); - sg4::ActorPtr actor = sg4::Actor::create(name, lilibeth, thread_create_wrapper, start_routine, arg); + sg4::ActorPtr actor = sg4::Actor::create( + name, lilibeth, + [](auto* user_function, auto* param) { +#if HAVE_SMPI + if (SMPI_is_inited()) + SMPI_thread_create(); +#endif + sthread_enable(); + user_function(param); + sthread_disable(); + }, + start_routine, arg); intrusive_ptr_add_ref(actor.get()); *thread = reinterpret_cast(actor.get()); -- 2.20.1