Null_Semaphore.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    Null_Semaphore.h
00006  *
00007  *  Null_Semaphore.h,v 4.5 2006/02/10 10:08:52 jwillemsen Exp
00008  *
00009  *   Moved from Synch.h.
00010  *
00011  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00012  */
00013 //==========================================================================
00014 
00015 #ifndef ACE_NULL_SEMAPHORE_H
00016 #define ACE_NULL_SEMAPHORE_H
00017 #include /**/ "ace/pre.h"
00018 
00019 // All methods in this class are inline, so there is no
00020 // need to import or export on Windows. -- CAE 12/18/2003
00021 #include "ace/os_include/os_errno.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 class ACE_Time_Value;
00030 
00031 /**
00032  * @class ACE_Null_Semaphore
00033  *
00034  * @brief Implement a do nothing ACE_Semaphore, i.e., all the methods are
00035  * no ops.
00036  *
00037  * Although the methods are no-ops, the return values are different for
00038  * the blocking as opposed to timed acquires.  The blocking version of
00039  * acquire() is often used to serialize access to a critical section,
00040  * whereas the timed version is often used to wait for another thread
00041  * to update some condition or change some shared state.  When using an
00042  * ACE_Null_Semaphore, however, there's no other thread involved to
00043  * change a state or condition (otherwise, a null semaphore would be
00044  * inappropriate).  Returning an error value signifies that the
00045  * state or condition has not been (and can't be) changed, which is
00046  * consistent with the behavior of the threaded case where a timeout
00047  * occurs before the state or condition is changed.
00048  */
00049 class ACE_Null_Semaphore
00050 {
00051 public:
00052   ACE_Null_Semaphore (unsigned int = 1,
00053                        int = 0,
00054                        const ACE_TCHAR * = 0,
00055                        void * = 0,
00056                        int = 0x7fffffff) {}
00057   ~ACE_Null_Semaphore (void) {}
00058   /// Return 0.
00059   int remove (void) {return 0;}
00060 
00061   /// Return 0.
00062   int acquire (void) {return 0;}
00063 
00064   /// Return -1 with <errno> == <ETIME>.
00065   int acquire (ACE_Time_Value &) {errno = ETIME; return -1;}
00066 
00067   /// Return -1 with <errno> == <ETIME>.
00068   int acquire (ACE_Time_Value *) {errno = ETIME; return -1;}
00069 
00070   /// Return 0.
00071   int tryacquire (void) {return 0;}
00072 
00073   /// Return 0.
00074   int release (void) {return 0;}
00075 
00076   /// Return 0.
00077   int release (size_t) {return 0;}
00078 
00079   /// Return 0.
00080   int acquire_write (void) {return 0;}
00081 
00082   /// Return 0.
00083   int tryacquire_write (void) {return 0;}
00084 
00085   /// Return 0.
00086   int tryacquire_write_upgrade (void) {return 0;}
00087 
00088   /// Return 0.
00089   int acquire_read (void) {return 0;}
00090 
00091   /// Return 0.
00092   int tryacquire_read (void) {return 0;}
00093 
00094   /// Dump the state of an object.
00095   void dump (void) const {}
00096 
00097   /// Declare the dynamic allocation hooks.
00098   //ACE_ALLOC_HOOK_DECLARE;
00099 };
00100 
00101 ACE_END_VERSIONED_NAMESPACE_DECL
00102 
00103 #include /**/ "ace/post.h"
00104 #endif /* ACE_NULL_SEMAPHORE_H */

Generated on Thu Nov 9 09:41:57 2006 for ACE by doxygen 1.3.6