3 //==========================================================================
5 * @file Null_Semaphore.h
9 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
11 //==========================================================================
13 #ifndef ACE_NULL_SEMAPHORE_H
14 #define ACE_NULL_SEMAPHORE_H
15 #include /**/ "ace/pre.h"
17 #include "ace/os_include/os_errno.h"
18 #include "ace/os_include/sys/os_types.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 * @class ACE_Null_Semaphore
31 * @brief Implement a do nothing ACE_Semaphore, i.e., all the methods are
34 * Although the methods are no-ops, the return values are different for
35 * the blocking as opposed to timed acquires. The blocking version of
36 * acquire() is often used to serialize access to a critical section,
37 * whereas the timed version is often used to wait for another thread
38 * to update some condition or change some shared state. When using an
39 * ACE_Null_Semaphore, however, there's no other thread involved to
40 * change a state or condition (otherwise, a null semaphore would be
41 * inappropriate). Returning an error value signifies that the
42 * state or condition has not been (and can't be) changed, which is
43 * consistent with the behavior of the threaded case where a timeout
44 * occurs before the state or condition is changed.
46 class ACE_Null_Semaphore
49 ACE_Null_Semaphore (unsigned int = 1,
51 const ACE_TCHAR
* = 0,
54 ~ACE_Null_Semaphore (void) {}
56 int remove (void) {return 0;}
59 int acquire (void) {return 0;}
61 /// Return -1 with @c errno == @c ETIME.
62 int acquire (ACE_Time_Value
&) {errno
= ETIME
; return -1;}
64 /// Return -1 with @c errno == @c ETIME.
65 int acquire (ACE_Time_Value
*) {errno
= ETIME
; return -1;}
68 int tryacquire (void) {return 0;}
71 int release (void) {return 0;}
74 int release (size_t) {return 0;}
77 int acquire_write (void) {return 0;}
80 int tryacquire_write (void) {return 0;}
83 int tryacquire_write_upgrade (void) {return 0;}
86 int acquire_read (void) {return 0;}
89 int tryacquire_read (void) {return 0;}
91 /// Dump the state of an object.
92 void dump (void) const {}
94 /// Declare the dynamic allocation hooks.
95 //ACE_ALLOC_HOOK_DECLARE;
98 ACE_END_VERSIONED_NAMESPACE_DECL
100 #include /**/ "ace/post.h"
101 #endif /* ACE_NULL_SEMAPHORE_H */