summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>1997-11-22 23:54:55 +0000
committerSteve Huston <shuston@riverace.com>1997-11-22 23:54:55 +0000
commit86290284f53bab6ef5ba6af0590ab9672f6d3e75 (patch)
tree6d1366389fcfabf66aa965471882bd148bf9ed33
parentbf3a9f292bebf9d1a253460e72e4ac4c53d28441 (diff)
downloadATCD-86290284f53bab6ef5ba6af0590ab9672f6d3e75.tar.gz
Moved class Errno out from thread_specific.cpp and tss1.cpp to a new
header file, thread_specific.h. AIX needs the class in a .h file.
-rw-r--r--examples/Threads/thread_specific.cpp45
-rw-r--r--examples/Threads/thread_specific.h50
-rw-r--r--examples/Threads/tss1.cpp38
3 files changed, 53 insertions, 80 deletions
diff --git a/examples/Threads/thread_specific.cpp b/examples/Threads/thread_specific.cpp
index 8baa46f6f8f..48b48bfec61 100644
--- a/examples/Threads/thread_specific.cpp
+++ b/examples/Threads/thread_specific.cpp
@@ -6,50 +6,7 @@
#if defined (ACE_HAS_THREADS)
-// Define a class that will be stored in thread-specific data. Note
-// that as far as this class is concerned it's just a regular C++
-// class. The ACE_TSS wrapper transparently ensures that objects of
-// this class will be placed in thread-specific storage. All calls on
-// ACE_TSS::operator->() are delegated to the appropriate method in
-// the Errno class.
-
-class Errno
-{
-public:
- int error (void) { return this->errno_; }
- void error (int i) { this->errno_ = i; }
-
- int line (void) { return this->lineno_; }
- void line (int l) { this->lineno_ = l; }
-
- // Errno::flags_ is a static variable, so we've got to protect it
- // with a mutex since it isn't kept in thread-specific storage.
- int flags (void)
- {
- ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Errno::lock_, -1);
-
- return Errno::flags_;
- }
-
- void flags (int f)
- {
- ACE_GUARD (ACE_Thread_Mutex, ace_mon, Errno::lock_);
-
- Errno::flags_ = f;
- }
-
-private:
- // = errno_ and lineno_ will be thread-specific data so they don't
- // need a lock.
- int errno_;
- int lineno_;
-
- static int flags_;
-#if defined (ACE_HAS_THREADS)
- // flags_ needs a lock.
- static ACE_Thread_Mutex lock_;
-#endif /* ACE_HAS_THREADS */
-};
+#include "thread_specific.h"
// Static variables.
ACE_MT (ACE_Thread_Mutex Errno::lock_);
diff --git a/examples/Threads/thread_specific.h b/examples/Threads/thread_specific.h
new file mode 100644
index 00000000000..bf031ee7aa9
--- /dev/null
+++ b/examples/Threads/thread_specific.h
@@ -0,0 +1,50 @@
+// $Id$
+
+#ifndef ACE_THREAD_SPECIFIC_H
+
+// Define a class that will be stored in thread-specific data. Note
+// that as far as this class is concerned it's just a regular C++
+// class. The ACE_TSS wrapper transparently ensures that objects of
+// this class will be placed in thread-specific storage. All calls on
+// ACE_TSS::operator->() are delegated to the appropriate method in
+// the Errno class.
+
+class Errno
+{
+public:
+ int error (void) { return this->errno_; }
+ void error (int i) { this->errno_ = i; }
+
+ int line (void) { return this->lineno_; }
+ void line (int l) { this->lineno_ = l; }
+
+ // Errno::flags_ is a static variable, so we've got to protect it
+ // with a mutex since it isn't kept in thread-specific storage.
+ int flags (void)
+ {
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Errno::lock_, -1);
+
+ return Errno::flags_;
+ }
+
+ void flags (int f)
+ {
+ ACE_GUARD (ACE_Thread_Mutex, ace_mon, Errno::lock_);
+
+ Errno::flags_ = f;
+ }
+
+private:
+ // = errno_ and lineno_ will be thread-specific data so they don't
+ // need a lock.
+ int errno_;
+ int lineno_;
+
+ static int flags_;
+#if defined (ACE_HAS_THREADS)
+ // flags_ needs a lock.
+ static ACE_Thread_Mutex lock_;
+#endif /* ACE_HAS_THREADS */
+};
+
+#endif /* ACE_THREAD_SPECIFIC_H */
diff --git a/examples/Threads/tss1.cpp b/examples/Threads/tss1.cpp
index cc3c863d1a3..1d0a76c788d 100644
--- a/examples/Threads/tss1.cpp
+++ b/examples/Threads/tss1.cpp
@@ -27,45 +27,11 @@
#if defined (ACE_HAS_THREADS)
+#include "thread_specific.h"
+
// (Sun C++ 4.2 with -O3 won't link if the following is not const.)
static const int iterations = 100;
-class Errno
-{
-public:
- int error (void) { return this->errno_; }
- void error (int i) { this->errno_ = i; }
-
- int line (void) { return this->lineno_; }
- void line (int l) { this->lineno_ = l; }
-
- // Errno::flags_ is a static variable, so we've got to protect it
- // with a mutex since it isn't kept in thread-specific storage.
- int flags (void) {
- ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_Mon, Errno::lock_, -1));
-
- return Errno::flags_;
- }
- int flags (int f)
- {
- ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Errno::lock_, -1));
-
- Errno::flags_ = f;
- return 0;
- }
-
-private:
- // = errno_ and lineno_ will be thread-specific data so they don't
- // need a lock.
- int errno_;
- int lineno_;
-
- static int flags_;
-#if defined (ACE_HAS_THREADS)
- // flags_ needs a lock.
- static ACE_Thread_Mutex lock_;
-#endif /* ACE_HAS_THREADS */
-};
// Static variables.
ACE_MT (ACE_Thread_Mutex Errno::lock_);