summaryrefslogtreecommitdiff
path: root/ace/Test_and_Set.cpp
diff options
context:
space:
mode:
authordoccvs <doccvs@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-10-13 01:21:57 +0000
committerdoccvs <doccvs@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-10-13 01:21:57 +0000
commit7160e530fc43393be47a655ce100e1fc125dc6d9 (patch)
tree05479c9b98febc8a45460fec03442753e5a81f0e /ace/Test_and_Set.cpp
parent6aeced075745800ab99d5386488da57b1afa9b67 (diff)
downloadATCD-7160e530fc43393be47a655ce100e1fc125dc6d9.tar.gz
ChangeLogTag: Thu Oct 12 18:19:46 2000 Priyanka Gontla <pgontla@ece.uci.edu>
Diffstat (limited to 'ace/Test_and_Set.cpp')
-rw-r--r--ace/Test_and_Set.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/ace/Test_and_Set.cpp b/ace/Test_and_Set.cpp
new file mode 100644
index 00000000000..20ff024fb17
--- /dev/null
+++ b/ace/Test_and_Set.cpp
@@ -0,0 +1,48 @@
+// $Id$
+
+#ifndef ACE_TEST_AND_SET_H
+#define ACE_TEST_AND_SET_H
+
+#include "ace/Thread.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "Test_and_Set.h"
+
+ACE_RCSID(ace, Test_and_Set, "$Id$")
+
+template <class ACE_LOCK, class TYPE>
+ACE_Test_and_Set<ACE_LOCK, TYPE>::ACE_Test_and_Set (TYPE initial_value)
+ : is_set_ (initial_value)
+{
+}
+
+// Returns true if we are done, else false.
+template <class ACE_LOCK, class TYPE> TYPE
+ACE_Test_and_Set<ACE_LOCK, TYPE>::is_set (void) const
+{
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->lock_, this->is_set_);
+ return this->is_set_;
+}
+
+// Sets the <is_set_> status.
+template <class ACE_LOCK, class TYPE> TYPE
+ACE_Test_and_Set<ACE_LOCK, TYPE>::set (TYPE status)
+{
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, this->is_set_);
+ TYPE o_status = this->is_set_;
+ this->is_set_ = status;
+ return o_status;
+}
+
+template <class ACE_LOCK, class TYPE> int
+ACE_Test_and_Set<ACE_LOCK, TYPE>::handle_signal (int, siginfo_t *, ucontext_t *)
+{
+ // By setting this to 1, we are "signaling" to anyone calling
+ // <is_set> or or <set> that the "test and set" object is in the
+ // "signaled" state, i.e., it's "available" to be set back to 0.
+ this->set (1);
+ return 0;
+}