Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of xbt_os_thread_yield() using C++11
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 18 Jul 2018 20:28:45 +0000 (22:28 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 18 Jul 2018 20:28:45 +0000 (22:28 +0200)
ChangeLog
include/xbt/xbt_os_thread.h
src/include/xbt/parmap.hpp
src/xbt/xbt_os_thread.c

index f53f1af..38b1e5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ Tracing:
 XBT:
  - Remove xbt_os_thread_specific features
  - Remove portability wrapper to condition variables
+ - Remove xbt_os_thread_yield()
 
 Fixed bugs:
  - #264: Add ptask L07 resource tracing
index 5c4f2ae..e1591c7 100644 (file)
@@ -38,7 +38,6 @@ XBT_PUBLIC void xbt_os_thread_set_extra_data(void* data);
 XBT_PUBLIC void* xbt_os_thread_get_extra_data(void);
 /* xbt_os_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
 XBT_PUBLIC void xbt_os_thread_join(xbt_os_thread_t thread, void** thread_return);
-XBT_PUBLIC void xbt_os_thread_yield(void);
 XBT_PUBLIC void xbt_os_thread_setstacksize(int stack_size);
 XBT_PUBLIC void xbt_os_thread_setguardsize(int guard_size);
 XBT_PUBLIC int xbt_os_thread_bind(xbt_os_thread_t thread, int core);
index b5b72de..b8fbed6 100644 (file)
@@ -15,6 +15,7 @@
 #include <boost/optional.hpp>
 #include <condition_variable>
 #include <mutex>
+#include <thread>
 
 #if HAVE_FUTEX_H
 #include <linux/futex.h>
@@ -411,7 +412,7 @@ template <typename T> void Parmap<T>::BusyWaitSynchro::master_signal()
 template <typename T> void Parmap<T>::BusyWaitSynchro::master_wait()
 {
   while (__atomic_load_n(&this->parmap.thread_counter, __ATOMIC_SEQ_CST) < this->parmap.num_workers) {
-    xbt_os_thread_yield();
+    std::this_thread::yield();
   }
 }
 
@@ -424,7 +425,7 @@ template <typename T> void Parmap<T>::BusyWaitSynchro::worker_wait(unsigned roun
 {
   /* wait for more work */
   while (__atomic_load_n(&this->parmap.work_round, __ATOMIC_SEQ_CST) != round) {
-    xbt_os_thread_yield();
+    std::this_thread::yield();
   }
 }
 
index fc6b574..79242cd 100644 (file)
@@ -246,12 +246,6 @@ xbt_os_thread_t xbt_os_thread_self(void )
   return pthread_getspecific(xbt_self_thread_key);
 }
 
-#include <sched.h>
-void xbt_os_thread_yield(void)
-{
-  sched_yield();
-}
-
 /****** mutex related functions ******/
 typedef struct xbt_os_mutex_ {
   pthread_mutex_t m;