Null_Semaphore.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    Null_Semaphore.h
00006  *
00007  *  $Id: Null_Semaphore.h 80826 2008-03-04 14:51:23Z wotte $
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 #include "ace/os_include/sys/os_types.h"
00023 
00024 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 # pragma once
00026 #endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 class ACE_Time_Value;
00031 
00032 /**
00033  * @class ACE_Null_Semaphore
00034  *
00035  * @brief Implement a do nothing ACE_Semaphore, i.e., all the methods are
00036  * no ops.
00037  *
00038  * Although the methods are no-ops, the return values are different for
00039  * the blocking as opposed to timed acquires.  The blocking version of
00040  * acquire() is often used to serialize access to a critical section,
00041  * whereas the timed version is often used to wait for another thread
00042  * to update some condition or change some shared state.  When using an
00043  * ACE_Null_Semaphore, however, there's no other thread involved to
00044  * change a state or condition (otherwise, a null semaphore would be
00045  * inappropriate).  Returning an error value signifies that the
00046  * state or condition has not been (and can't be) changed, which is
00047  * consistent with the behavior of the threaded case where a timeout
00048  * occurs before the state or condition is changed.
00049  */
00050 class ACE_Null_Semaphore
00051 {
00052 public:
00053   ACE_Null_Semaphore (unsigned int = 1,
00054                        int = 0,
00055                        const ACE_TCHAR * = 0,
00056                        void * = 0,
00057                        int = 0x7fffffff) {}
00058   ~ACE_Null_Semaphore (void) {}
00059   /// Return 0.
00060   int remove (void) {return 0;}
00061 
00062   /// Return 0.
00063   int acquire (void) {return 0;}
00064 
00065   /// Return -1 with @c errno == @c ETIME.
00066   int acquire (ACE_Time_Value &) {errno = ETIME; return -1;}
00067 
00068   /// Return -1 with @c errno == @c ETIME.
00069   int acquire (ACE_Time_Value *) {errno = ETIME; return -1;}
00070 
00071   /// Return 0.
00072   int tryacquire (void) {return 0;}
00073 
00074   /// Return 0.
00075   int release (void) {return 0;}
00076 
00077   /// Return 0.
00078   int release (size_t) {return 0;}
00079 
00080   /// Return 0.
00081   int acquire_write (void) {return 0;}
00082 
00083   /// Return 0.
00084   int tryacquire_write (void) {return 0;}
00085 
00086   /// Return 0.
00087   int tryacquire_write_upgrade (void) {return 0;}
00088 
00089   /// Return 0.
00090   int acquire_read (void) {return 0;}
00091 
00092   /// Return 0.
00093   int tryacquire_read (void) {return 0;}
00094 
00095   /// Dump the state of an object.
00096   void dump (void) const {}
00097 
00098   /// Declare the dynamic allocation hooks.
00099   //ACE_ALLOC_HOOK_DECLARE;
00100 };
00101 
00102 ACE_END_VERSIONED_NAMESPACE_DECL
00103 
00104 #include /**/ "ace/post.h"
00105 #endif /* ACE_NULL_SEMAPHORE_H */

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7