summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-23 15:19:19 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-23 15:19:19 +0000
commitc09d89edab31d56f623e89ad40f48fe61fda6222 (patch)
treee605f2c16242e9ab198dc21587e1f00aa594ff6d
parent662bb105a2e3f05069708ef2c7258cdc3881504c (diff)
downloadATCD-c09d89edab31d56f623e89ad40f48fe61fda6222.tar.gz
(worker): declare "u" globally so that we don't quickly run out of TSS keys.
-rw-r--r--tests/TSS_Test.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/TSS_Test.cpp b/tests/TSS_Test.cpp
index 7ce84b2f808..9cc8d1c9d87 100644
--- a/tests/TSS_Test.cpp
+++ b/tests/TSS_Test.cpp
@@ -53,6 +53,9 @@ ACE_Thread_Mutex *Errno::lock_ = 0;
// This is our thread-specific error handler...
// See comment below about why it's dynamically allocated.
static ACE_TSS<Errno> *tss_error;
+// This is for testing/demonstrating ACE_TSS_Type_Adapter. It's
+// dynamically allocated to avoid static objects, also.
+static ACE_TSS<ACE_TSS_Type_Adapter<u_int> > *u;
// Serializes output.
static ACE_Thread_Mutex output_lock;
@@ -150,14 +153,14 @@ worker (void *c)
// class ACE_TSS_Type_Adapter in ace/Synch_T.h for what this
// should look like. Unfortunately, some compilers have trouble
// with the implicit type conversions.
- ACE_TSS<ACE_TSS_Type_Adapter<u_int> > u;
- u->operator u_int & () = 37;
- if (u->operator u_int () != 37)
+ (*u)->operator u_int & () = 37;
+ if ((*u)->operator u_int () != 37)
{
// Use the guard to serialize access to errors.
- ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, output_lock, 0));
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, output_lock,
+ 0));
ACE_DEBUG ((LM_ERROR, "use of ACE_TSS_Type_Adapter failed, value "
- "is %u, it should be 37!\n", u->operator u_int ()));
+ "is %u, it should be 37!\n", (*u)->operator u_int ()));
++errors;
}
@@ -242,6 +245,9 @@ main (int, ASYS_TCHAR *[])
// ACE_Allocator.
ACE_NEW_RETURN (tss_error, ACE_TSS<Errno>, 1);
+ // Similarly, dynamically allocate u.
+ ACE_NEW_RETURN (u, ACE_TSS<ACE_TSS_Type_Adapter<u_int> >, 1);
+
// Register a signal handler.
ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
ACE_UNUSED_ARG (sa);
@@ -255,7 +261,10 @@ main (int, ASYS_TCHAR *[])
ACE_Thread_Manager::instance ()->wait ();
+ delete u;
+ u = 0;
delete tss_error;
+ tss_error = 0;
Errno::deallocate_lock ();
#else