X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b283430cb109f0ef78eaeba48f8942b512c659d2..745a5ade14924e2b2684a280e4cb75a9c1d3bee7:/src/xbt/xbt_os_synchro.cpp diff --git a/src/xbt/xbt_os_synchro.cpp b/src/xbt/xbt_os_synchro.cpp index 748faa20c7..1992ab40f2 100644 --- a/src/xbt/xbt_os_synchro.cpp +++ b/src/xbt/xbt_os_synchro.cpp @@ -1,15 +1,16 @@ /* Classical synchro schema, implemented on top of SimGrid */ -/* Copyright (c) 2007-2016. The SimGrid Team. +/* Copyright (c) 2007-2019. 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. */ -#include "xbt/ex.h" -#include "xbt/synchro.h" - +#include "simgrid/Exception.hpp" #include "simgrid/simix.h" /* used implementation */ +#include "src/kernel/activity/ConditionVariableImpl.hpp" +#include "src/kernel/activity/MutexImpl.hpp" +#include "xbt/synchro.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt, "Synchronization mechanism"); @@ -36,7 +37,8 @@ void xbt_mutex_release(xbt_mutex_t mutex) void xbt_mutex_destroy(xbt_mutex_t mutex) { - SIMIX_mutex_unref((smx_mutex_t)mutex); + if (mutex != nullptr) + mutex->unref(); } /***** condition related functions *****/ @@ -50,22 +52,22 @@ void xbt_cond_wait(xbt_cond_t cond, xbt_mutex_t mutex) simcall_cond_wait((smx_cond_t)cond, (smx_mutex_t)mutex); } -void xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay) +int xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay) { - simcall_cond_wait_timeout((smx_cond_t)cond, (smx_mutex_t)mutex, delay); + return simcall_cond_wait_timeout((smx_cond_t)cond, (smx_mutex_t)mutex, delay); } void xbt_cond_signal(xbt_cond_t cond) { - simcall_cond_signal((smx_cond_t)cond); + cond->cond_.notify_one(); } void xbt_cond_broadcast(xbt_cond_t cond) { - simcall_cond_broadcast((smx_cond_t)cond); + cond->cond_.notify_all(); } void xbt_cond_destroy(xbt_cond_t cond) { - SIMIX_cond_unref((smx_cond_t)cond); + delete cond; }