summaryrefslogtreecommitdiff
path: root/TAO/tao/Condition.h
diff options
context:
space:
mode:
authorbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-04-04 04:26:10 +0000
committerbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-04-04 04:26:10 +0000
commit49e28172fde149655832e3f58e9a8d91c4e394c3 (patch)
tree866f51c285d8f0d3c1cd2a53a0194d493825e847 /TAO/tao/Condition.h
parentcf868907d58e193c4cff75a0bd0d5122661db91e (diff)
downloadATCD-49e28172fde149655832e3f58e9a8d91c4e394c3.tar.gz
ChangeLogTag: Wed Apr 3 22:18:38 2002 Balachandran Natarajan <bala@cs.wustl.edu>
Diffstat (limited to 'TAO/tao/Condition.h')
-rw-r--r--TAO/tao/Condition.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/TAO/tao/Condition.h b/TAO/tao/Condition.h
new file mode 100644
index 00000000000..b9b85a4c817
--- /dev/null
+++ b/TAO/tao/Condition.h
@@ -0,0 +1,115 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file Condition.h
+ *
+ * $Id$
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_CONDITION_H
+#define TAO_CONDITION_H
+#include "ace/pre.h"
+
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+/**
+ * @class TAO_Condition
+ *
+ * @brief Same as to the ACE_Condition variable wrapper
+ *
+ * This class differs from ACE_Condition in that it uses a
+ * TAO_SYNCH_CONDITION instead of ACE_cond_t under the hood to
+ * provide blocking.
+ */
+template <class MUTEX>
+class TAO_Condition
+{
+public:
+
+ /// Useful typedef
+ typedef MUTEX LOCK;
+
+ // = Initialiation and termination methods.
+ /// Initialize the condition variable.
+ TAO_Condition (MUTEX &m);
+
+ /// A default constructor. Since no lock is provided by the user,
+ /// one will be created internally.
+ TAO_Condition (void);
+
+ /// Implicitly destroy the condition variable.
+ ~TAO_Condition (void);
+
+ // = Lock accessors.
+ /**
+ * Block on condition, or until absolute time-of-day has passed. If
+ * abstime == 0 use "blocking" <wait> semantics. Else, if <abstime>
+ * != 0 and the call times out before the condition is signaled
+ * <wait> returns -1 and sets errno to ETIME.
+ */
+ int wait (const ACE_Time_Value *abstime);
+
+ /// Block on condition.
+ int wait (void);
+
+ /**
+ * Block on condition or until absolute time-of-day has passed. If
+ * abstime == 0 use "blocking" wait() semantics on the <mutex>
+ * passed as a parameter (this is useful if you need to store the
+ * <Condition> in shared memory). Else, if <abstime> != 0 and the
+ * call times out before the condition is signaled <wait> returns -1
+ * and sets errno to ETIME.
+ */
+ int wait (MUTEX &mutex, const ACE_Time_Value *abstime = 0);
+
+ /// Signal one waiting thread.
+ int signal (void);
+
+ /// Signal *all* waiting threads.
+ int broadcast (void);
+
+ // = Utility methods.
+ /// Explicitly destroy the condition variable.
+ int remove (void);
+
+ /// Returns a reference to the underlying mutex_;
+ MUTEX *mutex (void);
+
+private:
+
+ /// Reference to mutex lock.
+ MUTEX *mutex_;
+
+ /// A flag to indicate whether the lock needs to be deleted.
+ int delete_lock_;
+
+ /// Condition variable.
+ TAO_SYNCH_CONDITION *cond_;
+
+ // = Prevent assignment and initialization.
+ ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Condition<MUTEX> &))
+ ACE_UNIMPLEMENTED_FUNC (TAO_Condition (const TAO_Condition<MUTEX> &))
+};
+
+#if defined (__ACE_INLINE__)
+#include "Condition.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
+#include "Condition.cpp"
+#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
+
+#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
+#pragma implementation ("Condition.cpp")
+#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
+
+#include "ace/post.h"
+#endif /*TAO_CONDITION_H*/