2 //=============================================================================
4 * @file Bug_3539_Regression_Test.cpp
6 * This test is similar to TSS_Test but it's a bit simpler and it uses
7 * ACE_TSS in a main() thread. It uses TSS_Test_Errno.h.
9 * @author Vladimir Zykov <vz@prismtech.com>
11 //=============================================================================
14 #include "test_config.h"
15 #include "TSS_Test_Errno.h"
17 #include "ace/TSS_T.h"
18 #include "ace/Thread_Manager.h"
19 #include "ace/Atomic_Op_T.h"
21 ACE_Atomic_Op
<ACE_SYNCH_MUTEX
, int> status
;
23 #if defined (ACE_HAS_THREADS)
28 ACE_TSS_TYPE (Errno
) tss_
;
35 ACE_Thread_Mutex
*Errno::lock_
= 0;
38 check_tss (ObjectWithTSS
*o
)
47 Errno
*e
= o
->tss_
.ts_object (0);
51 "TSS should not have any value yet."));
55 e
= ACE_TSS_GET (&o
->tss_
, Errno
);
59 "TSS should now have a value."));
66 // This worker function is the entry point for each thread.
70 return check_tss (reinterpret_cast<ObjectWithTSS
*> (c
));
73 #endif /* ACE_HAS_THREADS */
76 run_main (int, ACE_TCHAR
*[])
78 ACE_START_TEST (ACE_TEXT ("Bug_3539_Regression_Test"));
80 #if defined (ACE_HAS_THREADS)
81 Errno::allocate_lock ();
83 const u_int threads
= ACE_MAX_THREADS
;
87 ACE_NEW_RETURN (o
, ObjectWithTSS
, 1);
88 std::unique_ptr
<ObjectWithTSS
> owner (o
);
90 if (ACE_Thread_Manager::instance ()->spawn_n
92 ACE_THR_FUNC (worker
),
95 ACE_ERROR_RETURN ((LM_ERROR
,
96 ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n")),
101 ACE_Thread_Manager::instance ()->wait ();
104 Errno::deallocate_lock ();
106 if (Errno::created () != Errno::deleted ())
108 ACE_ERROR_RETURN ((LM_ERROR
,
109 ACE_TEXT ("Number created (%d) ")
110 ACE_TEXT ("!= number deleted (%d)\n"),
111 Errno::created (), Errno::deleted ()),
115 #else /* ACE_HAS_THREADS */
117 ACE_TEXT ("threads are not supported on this platform\n")));
118 #endif /* ACE_HAS_THREADS */
121 return status
.value ();