3 //==========================================================================
5 * @file Thread_Semaphore.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //==========================================================================
11 #ifndef ACE_THREAD_SEMAPHORE_H
12 #define ACE_THREAD_SEMAPHORE_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/ACE_export.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #if !defined (ACE_HAS_THREADS)
22 # include "ace/Null_Semaphore.h"
23 #else /* ACE_HAS_THREADS */
24 // ACE platform supports some form of threading.
26 #include "ace/Semaphore.h"
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 * @class ACE_Thread_Semaphore
33 * @brief Wrapper for Dijkstra style general semaphores that work
34 * only within one process.
36 class ACE_Export ACE_Thread_Semaphore
: public ACE_Semaphore
39 /// Initialize the semaphore, with an initial value of @a count,
40 /// maximum value of @a max, and unlocked by default.
41 ACE_Thread_Semaphore (unsigned int count
= 1, // By default make this unlocked.
42 const ACE_TCHAR
*name
= 0,
44 int max
= 0x7FFFFFFF);
46 /// Default destructor.
47 ~ACE_Thread_Semaphore ();
49 /// Dump the state of an object.
52 /// Declare the dynamic allocation hooks.
53 ACE_ALLOC_HOOK_DECLARE
;
56 /*****************************************************************************/
58 template <class T
> class ACE_Malloc_Lock_Adapter_T
;
61 * @brief Template specialization of ACE_Malloc_Lock_Adapter_T for
62 * ACE_Thread_Semaphore.
64 * This is needed since the ctor for ACE_Thread_Semaphore doesn't match
65 * the standard form used by other lock strategy classes.
68 class ACE_Export ACE_Malloc_Lock_Adapter_T
<ACE_Thread_Semaphore
>
71 ACE_Thread_Semaphore
* operator () (const ACE_TCHAR
*name
);
74 ACE_END_VERSIONED_NAMESPACE_DECL
76 #if defined (__ACE_INLINE__)
77 #include "ace/Thread_Semaphore.inl"
78 #endif /* __ACE_INLINE__ */
80 #endif /* !ACE_HAS_THREADS */
82 #include /**/ "ace/post.h"
83 #endif /* ACE_THREAD_SEMAPHORE_H */