Main MRPT website > C++ reference for MRPT 1.5.5
CSemaphore.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef mrpt_synch_semaphore_H
10 #define mrpt_synch_semaphore_H
11 
13 #include <string>
14 
15 namespace mrpt
16 {
17  namespace synch
18  {
19  /** A semaphore for inter-thread synchronization.
20  * The state of a semaphore object is signaled when its count is greater than zero,
21  * and nonsignaled when its count is equal to zero. The initialCount parameter specifies
22  * the initial count. Each time a waiting thread is released because of the semaphore's
23  * signaled state, the count of the semaphore is decreased by one. Use the release function
24  * to increment a semaphore's count by a specified amount. The count can never be less
25  * than zero or greater than the value specified in the maxCount parameter.
26  * \ingroup synch_grp
27  */
29  {
30  protected:
32  public:
33  /** Creates a semaphore.*/
34  CSemaphore(unsigned int initialCount, unsigned int maxCount);
35 
36  virtual ~CSemaphore(); //!< Dtor
37 
38  /** Blocks until the count of the semaphore to be non-zero.
39  * \param timeout_ms The timeout in milliseconds, or set to zero to wait indefinidely.
40  * \return true if the semaphore has been signaled, false on timeout or any other error.
41  */
42  bool waitForSignal( unsigned int timeout_ms = 0 );
43 
44  /** Increments the count of the semaphore by a given amount */
45  void release(unsigned int increaseCount = 1);
46  };
47 
48  } // End of namespace
49 } // End of namespace
50 #endif
Represents a memory block (via "void*") that can be shared between several objects through copy opera...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::utils::CReferencedMemBlock m_data
Definition: CSemaphore.h:31
GLsizei maxCount
Definition: glext.h:3902
A semaphore for inter-thread synchronization.
Definition: CSemaphore.h:28



Page generated by Doxygen 1.8.14 for MRPT 1.5.5 Git: e06b63dbf Fri Dec 1 14:41:11 2017 +0100 at lun oct 28 01:31:35 CET 2019