1 //=============================================================================
3 * @file Task_Wait_Test.cpp
5 * This program tests the ACE_Thread_Manager::wait() from a called-back
6 * ACE_Task::close() on thread exit.
8 * @author Steve Huston <shuston@riverace.com>
10 //=============================================================================
13 #include "test_config.h"
14 #include "ace/Event.h"
15 #include "ace/Thread_Manager.h"
17 #include "ace/OS_NS_unistd.h"
19 // On Windows, this test will deadlock because a thread tries to join with
20 // itself. Pthreads, et al, have deadlock protection in join; Windows Vista
21 // and Server 2003 have API to access the info needed to check for deadlock
22 // in ACE_OS::thr_join() - don't run this test on earlier Windows versions
23 // because it will hang/time out and there's little to be done about it.
24 #if defined (ACE_HAS_THREADS) && ((defined (_WIN32_WINNT) && (_WIN32_WINNT >= 0x0502)) || !defined (WIN32))
25 # define RUN_THIS_TEST
30 static ACE_Event TaskDone
;
32 // Define a ACE_Task that does little except exit and try to clean up.
34 class Do_Nothing_Task
: public ACE_Task_Base
{
36 int close (u_long flags
= 0) override
;
41 // close tries to wait for other threads. There aren't any, but as long as
42 // we don't deadlock, it's good.
44 Do_Nothing_Task::close (u_long
)
47 ACE_TEXT ("Task 0x%x, thread %t closing\n"),
55 // svc just waits a second then exits.
57 Do_Nothing_Task::svc ()
60 ACE_TEXT ("Task 0x%x, thread %t waiting to exit\n"),
67 #endif /* RUN_THIS_TEST */
70 run_main (int, ACE_TCHAR
*[])
72 ACE_START_TEST (ACE_TEXT ("Task_Wait_Test"));
75 #if defined (RUN_THIS_TEST)
78 status
= t
.activate ();
83 ACE_TEXT ("inadequate thread support on this platform\n")));
84 #endif /* RUN_THIS_TEST */