Thread_Semaphore.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    Thread_Semaphore.h
00006  *
00007  *  Thread_Semaphore.h,v 4.9 2005/11/26 03:13:13 ossama Exp
00008  *
00009  *   Moved from Synch.h.
00010  *
00011  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00012  */
00013 //==========================================================================
00014 
00015 #ifndef ACE_THREAD_SEMAPHORE_H
00016 #define ACE_THREAD_SEMAPHORE_H
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "ace/ACE_export.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #if !defined (ACE_HAS_THREADS)
00026 #  include "ace/Null_Semaphore.h"
00027 #else /* ACE_HAS_THREADS */
00028 // ACE platform supports some form of threading.
00029 
00030 #include "ace/Semaphore.h"
00031 
00032 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 /**
00035  * @class ACE_Thread_Semaphore
00036  *
00037  * @brief Wrapper for Dijkstra style general semaphores that work
00038  * only within one process.
00039  */
00040 class ACE_Export ACE_Thread_Semaphore : public ACE_Semaphore
00041 {
00042 public:
00043   /// Initialize the semaphore, with an initial value of @a count,
00044   /// maximum value of @a max, and unlocked by default.
00045   ACE_Thread_Semaphore (unsigned int count = 1, // By default make this unlocked.
00046                         const ACE_TCHAR *name = 0,
00047                         void * = 0,
00048                         int max = 0x7FFFFFFF);
00049 
00050   /// Default dtor.
00051   ~ACE_Thread_Semaphore (void);
00052 
00053   /// Dump the state of an object.
00054   void dump (void) const;
00055 
00056   /// Declare the dynamic allocation hooks.
00057   ACE_ALLOC_HOOK_DECLARE;
00058 };
00059 
00060 /*****************************************************************************/
00061 
00062 template <class T> class ACE_Malloc_Lock_Adapter_T;
00063 
00064 /**
00065  * @class ACE_Malloc_Lock_Adapter_T<ACE_Thread_Semaphore>
00066  *
00067  * @brief Template specialization of ACE_Malloc_Lock_Adapter_T for
00068  * ACE_Thread_Semaphore.
00069  *
00070  * This is needed since the ctor for ACE_Thread_Semaphore doesn't match
00071  * the standard form used by other lock strategy classes.
00072  */
00073 template<>
00074 class ACE_Export ACE_Malloc_Lock_Adapter_T<ACE_Thread_Semaphore>
00075 {
00076 public:
00077   ACE_Thread_Semaphore * operator () (const ACE_TCHAR *name);
00078 };
00079 
00080 ACE_END_VERSIONED_NAMESPACE_DECL
00081 
00082 #if defined (__ACE_INLINE__)
00083 #include "ace/Thread_Semaphore.inl"
00084 #endif /* __ACE_INLINE__ */
00085 
00086 #endif /* !ACE_HAS_THREADS */
00087 
00088 #include /**/ "ace/post.h"
00089 #endif /* ACE_THREAD_SEMAPHORE_H */

Generated on Thu Nov 9 09:42:06 2006 for ACE by doxygen 1.3.6