X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/009fecfd613cf13e7939dd650cce1625d5c7329f..b8df87e176f27b25534f27d7e240defa32ca35bc:/include/simgrid/s4u/Semaphore.hpp diff --git a/include/simgrid/s4u/Semaphore.hpp b/include/simgrid/s4u/Semaphore.hpp index 442b147eb1..c4b7a94f40 100644 --- a/include/simgrid/s4u/Semaphore.hpp +++ b/include/simgrid/s4u/Semaphore.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-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. */ @@ -21,21 +21,21 @@ namespace s4u { * Instead, you should use the present class, that offers a very similar interface. * * As for any S4U object, Semaphores are using the @ref s4u_raii "RAII idiom" for memory management. - * Use createSemaphore() to get a ::SemaphorePtr to a newly created semaphore - * and only manipulate ::SemaphorePtr. + * Use #create() to get a simgrid::s4u::SemaphorePtr to a newly created semaphore + * and only manipulate simgrid::s4u::SemaphorePtr. * */ class XBT_PUBLIC Semaphore { smx_sem_t sem_; std::atomic_int_fast32_t refcount_{0}; - explicit Semaphore(unsigned int initial_capacity); - ~Semaphore(); - friend void intrusive_ptr_add_ref(Semaphore* sem); friend void intrusive_ptr_release(Semaphore* sem); public: + explicit Semaphore(unsigned int initial_capacity); + ~Semaphore(); + // No copy: /** You cannot create a new semaphore by copying an existing one. Use SemaphorePtr instead */ Semaphore(Semaphore const&) = delete; @@ -46,7 +46,10 @@ public: static SemaphorePtr create(unsigned int initial_capacity); void acquire(); + int acquire_timeout(double timeout); void release(); + int get_capacity(); + int would_block(); }; }} // namespace simgrid::s4u