3 //==========================================================================
5 * @file Null_Semaphore.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //==========================================================================
11 #ifndef ACE_NULL_SEMAPHORE_H
12 #define ACE_NULL_SEMAPHORE_H
13 #include /**/ "ace/pre.h"
15 #include "ace/os_include/os_errno.h"
16 #include "ace/os_include/sys/os_types.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 * @class ACE_Null_Semaphore
29 * @brief Implement a do nothing ACE_Semaphore, i.e., all the methods are
32 * Although the methods are no-ops, the return values are different for
33 * the blocking as opposed to timed acquires. The blocking version of
34 * acquire() is often used to serialize access to a critical section,
35 * whereas the timed version is often used to wait for another thread
36 * to update some condition or change some shared state. When using an
37 * ACE_Null_Semaphore, however, there's no other thread involved to
38 * change a state or condition (otherwise, a null semaphore would be
39 * inappropriate). Returning an error value signifies that the
40 * state or condition has not been (and can't be) changed, which is
41 * consistent with the behavior of the threaded case where a timeout
42 * occurs before the state or condition is changed.
44 class ACE_Null_Semaphore
47 ACE_Null_Semaphore (unsigned int = 1,
49 const ACE_TCHAR
* = 0,
52 ~ACE_Null_Semaphore () = default;
54 int remove () {return 0;}
57 int acquire () {return 0;}
59 /// Return -1 with @c errno == @c ETIME.
60 int acquire (ACE_Time_Value
&) {errno
= ETIME
; return -1;}
62 /// Return -1 with @c errno == @c ETIME.
63 int acquire (ACE_Time_Value
*) {errno
= ETIME
; return -1;}
66 int tryacquire () {return 0;}
69 int release () {return 0;}
72 int release (size_t) {return 0;}
75 int acquire_write () {return 0;}
78 int tryacquire_write () {return 0;}
81 int tryacquire_write_upgrade () {return 0;}
84 int acquire_read () {return 0;}
87 int tryacquire_read () {return 0;}
89 /// Dump the state of an object.
92 /// Declare the dynamic allocation hooks.
93 //ACE_ALLOC_HOOK_DECLARE;
96 ACE_END_VERSIONED_NAMESPACE_DECL
98 #include /**/ "ace/post.h"
99 #endif /* ACE_NULL_SEMAPHORE_H */