summaryrefslogtreecommitdiff
path: root/ace/Null_Semaphore.h
diff options
context:
space:
mode:
authordhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-08-04 03:53:54 +0000
committerdhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-08-04 03:53:54 +0000
commit937a0506cb1c0980eab5bcfdf266139e1c93e80c (patch)
tree12103be26b2e9b0cd1869d7fd72a1f8a8ec362e6 /ace/Null_Semaphore.h
parent868bea2cbe0807f9db59c1997ede86af27fbc8e3 (diff)
downloadATCD-937a0506cb1c0980eab5bcfdf266139e1c93e80c.tar.gz
ChangeLogTag:Mon Aug 4 03:26:30 UTC 2003 Don Hinton <dhinton@dresystems.com>
Diffstat (limited to 'ace/Null_Semaphore.h')
-rw-r--r--ace/Null_Semaphore.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/ace/Null_Semaphore.h b/ace/Null_Semaphore.h
new file mode 100644
index 00000000000..fbd045f5455
--- /dev/null
+++ b/ace/Null_Semaphore.h
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+
+//==========================================================================
+/**
+ * @file Null_Semaphore.h
+ *
+ * $Id$
+ *
+ * Moved from Synch.h.
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+//==========================================================================
+
+#ifndef ACE_NULL_SEMAPHORE_H
+#define ACE_NULL_SEMAPHORE_H
+#include /**/ "ace/pre.h"
+
+#include "ace/ACE_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/os_include/os_errno.h"
+
+class ACE_Time_Value;
+
+/**
+ * @class ACE_Null_Semaphore
+ *
+ * @brief Implement a do nothing <ACE_Semaphore>, i.e., all the methods are
+ * no ops.
+ *
+ * Although the methods are no-ops, the return values are different for
+ * the blocking as opposed to timed acquires. The blocking version of
+ * acquire() is often used to serialize access to a critical section,
+ * whereas the timed version is often used to wait for another thread
+ * to update some condition or change some shared state. When using an
+ * ACE_Null_Semaphore, however, there's no other thread involved to
+ * change a state or condition (otherwise, a null semaphore would be
+ * inappropriate). Returning an error value signifies that the
+ * state or condition has not been (and can't be) changed, which is
+ * consistent with the behavior of the threaded case where a timeout
+ * occurs before the state or condition is changed.
+ */
+class ACE_Export ACE_Null_Semaphore
+{
+public:
+ ACE_Null_Semaphore (unsigned int count = 1, // By default make this unlocked.
+ int type = 0,
+ const ACE_TCHAR *name = 0,
+ void * = 0,
+ int max = 0x7fffffff) {}
+ ~ACE_Null_Semaphore (void) {}
+ /// Return 0.
+ int remove (void) {return 0;}
+
+ /// Return 0.
+ int acquire (void) {return 0;}
+
+ /// Return -1 with <errno> == <ETIME>.
+ int acquire (ACE_Time_Value &) {errno = ETIME; return -1;}
+
+ /// Return -1 with <errno> == <ETIME>.
+ int acquire (ACE_Time_Value *) {errno = ETIME; return -1;}
+
+ /// Return 0.
+ int tryacquire (void) {return 0;}
+
+ /// Return 0.
+ int release (void) {return 0;}
+
+ /// Return 0.
+ int release (size_t) {return 0;}
+
+ /// Return 0.
+ int acquire_write (void) {return 0;}
+
+ /// Return 0.
+ int tryacquire_write (void) {return 0;}
+
+ /// Return 0.
+ int tryacquire_write_upgrade (void) {return 0;}
+
+ /// Return 0.
+ int acquire_read (void) {return 0;}
+
+ /// Return 0.
+ int tryacquire_read (void) {return 0;}
+
+ /// Dump the state of an object.
+ void dump (void) const {}
+
+ /// Declare the dynamic allocation hooks.
+ //ACE_ALLOC_HOOK_DECLARE;
+};
+
+#include /**/ "ace/post.h"
+#endif /* ACE_NULL_SEMAPHORE_H */