1 /* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "simgrid/s4u/Mutex.hpp"
7 #include "src/kernel/activity/MutexImpl.hpp"
12 /** @brief Blocks the calling actor until the mutex can be obtained */
15 simcall_mutex_lock(mutex_);
18 /** @brief Release the ownership of the mutex, unleashing a blocked actor (if any)
20 * Will fail if the calling actor does not own the mutex.
24 simcall_mutex_unlock(mutex_);
27 /** @brief Acquire the mutex if it's free, and return false (without blocking) if not */
28 bool Mutex::try_lock()
30 return simcall_mutex_trylock(mutex_);
33 /** @brief Create a new mutex
37 MutexPtr Mutex::createMutex()
39 smx_mutex_t mutex = simcall_mutex_init();
40 return MutexPtr(&mutex->mutex(), false);