summaryrefslogtreecommitdiff
path: root/ACE/ace/Null_Semaphore.h
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:30 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:30 +0000
commitc44379cc7d9c7aa113989237ab0f56db12aa5219 (patch)
tree66a84b20d47f2269d8bdc6e0323f338763424d3a /ACE/ace/Null_Semaphore.h
parent3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (diff)
downloadATCD-c44379cc7d9c7aa113989237ab0f56db12aa5219.tar.gz
Repo restructuring
Diffstat (limited to 'ACE/ace/Null_Semaphore.h')
-rw-r--r--ACE/ace/Null_Semaphore.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/ACE/ace/Null_Semaphore.h b/ACE/ace/Null_Semaphore.h
new file mode 100644
index 00000000000..9124f46cf73
--- /dev/null
+++ b/ACE/ace/Null_Semaphore.h
@@ -0,0 +1,104 @@
+// -*- 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"
+
+// All methods in this class are inline, so there is no
+// need to import or export on Windows. -- CAE 12/18/2003
+#include "ace/os_include/os_errno.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+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_Null_Semaphore
+{
+public:
+ ACE_Null_Semaphore (unsigned int = 1,
+ int = 0,
+ const ACE_TCHAR * = 0,
+ void * = 0,
+ int = 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;
+};
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#include /**/ "ace/post.h"
+#endif /* ACE_NULL_SEMAPHORE_H */