X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/198b09ec16ca1b8fc05053bcae9e75c0ad689711..55e3e5942266691da7914fc1e9fdc894a802a966:/src/simix/smx_synchro_private.h diff --git a/src/simix/smx_synchro_private.h b/src/simix/smx_synchro_private.h index 73f87c1867..06bd94b76f 100644 --- a/src/simix/smx_synchro_private.h +++ b/src/simix/smx_synchro_private.h @@ -1,5 +1,4 @@ -/* Copyright (c) 2012, 2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2016. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -9,6 +8,9 @@ #include +#include +#include + #include "xbt/base.h" #include "xbt/swag.h" #include "xbt/xbt_os_thread.h" @@ -24,12 +26,12 @@ public: Mutex(Mutex const&) = delete; Mutex& operator=(Mutex const&) = delete; - void lock(smx_process_t issuer); - bool try_lock(smx_process_t issuer); - void unlock(smx_process_t issuer); + void lock(smx_actor_t issuer); + bool try_lock(smx_actor_t issuer); + void unlock(smx_actor_t issuer); bool locked = false; - smx_process_t owner = nullptr; + smx_actor_t owner = nullptr; // List of sleeping processes: xbt_swag_t sleeping = nullptr; @@ -48,17 +50,24 @@ public: if (count == 0) delete mutex; } + + simgrid::s4u::Mutex& mutex() { return mutex_; } + private: std::atomic_int_fast32_t refcount_ { 1 }; + simgrid::s4u::Mutex mutex_; }; } } typedef struct s_smx_cond { - smx_mutex_t mutex; - xbt_swag_t sleeping; /* list of sleeping process */ - std::atomic_int_fast32_t refcount_; + s_smx_cond() : cond_(this) {} + + std::atomic_int_fast32_t refcount_ { 1 }; + smx_mutex_t mutex = nullptr; + xbt_swag_t sleeping = nullptr; /* list of sleeping process */ + simgrid::s4u::ConditionVariable cond_; } s_smx_cond_t; typedef struct s_smx_sem { @@ -66,14 +75,12 @@ typedef struct s_smx_sem { xbt_swag_t sleeping; /* list of sleeping process */ } s_smx_sem_t; +XBT_PRIVATE void SIMIX_post_synchro(smx_activity_t synchro); +XBT_PRIVATE void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall); +XBT_PRIVATE void SIMIX_synchro_destroy(smx_activity_t synchro); +XBT_PRIVATE void SIMIX_synchro_finish(smx_activity_t synchro); - -XBT_PRIVATE void SIMIX_post_synchro(smx_synchro_t synchro); -XBT_PRIVATE void SIMIX_synchro_stop_waiting(smx_process_t process, smx_simcall_t simcall); -XBT_PRIVATE void SIMIX_synchro_destroy(smx_synchro_t synchro); -XBT_PRIVATE void SIMIX_synchro_finish(smx_synchro_t synchro); - -XBT_PRIVATE smx_cond_t SIMIX_cond_init(void); +XBT_PRIVATE smx_cond_t SIMIX_cond_init(); XBT_PRIVATE void SIMIX_cond_broadcast(smx_cond_t cond); XBT_PRIVATE void SIMIX_cond_signal(smx_cond_t cond); XBT_PRIVATE void intrusive_ptr_add_ref(s_smx_cond_t *cond);