diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-03-05 17:14:45 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-03-05 17:14:45 +0000 |
commit | 58033491c6d0bac82315c1fdb1ec9b39be58093f (patch) | |
tree | c69c3aa67ec66758066e959bd0d533ea336ec236 /tests/Timer_Cancellation_Test.cpp | |
parent | 2efc882384a34f61311a24fc641d1b5fd5776356 (diff) | |
download | ATCD-58033491c6d0bac82315c1fdb1ec9b39be58093f.tar.gz |
This commit was manufactured by cvs2svn to create tag 'TAO-1_5'.TAO-1_5
Diffstat (limited to 'tests/Timer_Cancellation_Test.cpp')
-rw-r--r-- | tests/Timer_Cancellation_Test.cpp | 162 |
1 files changed, 0 insertions, 162 deletions
diff --git a/tests/Timer_Cancellation_Test.cpp b/tests/Timer_Cancellation_Test.cpp deleted file mode 100644 index 0db3da521ae..00000000000 --- a/tests/Timer_Cancellation_Test.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// tests -// -// = FILENAME -// Timer_Cancellation_Test.cpp -// -// = DESCRIPTION -// A test to ensure the timer cancellation works correctly. -// -// = AUTHOR -// Irfan Pyarali <irfan@oomworks.com> -// -// ============================================================================ - -#include "tests/test_config.h" -#include "ace/OS_NS_unistd.h" -#include "ace/Reactor.h" -#include "ace/TP_Reactor.h" -#include "ace/Task.h" - -ACE_RCSID(tests, Timer_Cancellation_Test, "$Id$") - -#if defined (ACE_HAS_THREADS) - -class Deadlock : public ACE_Task_Base -{ -public: - - int svc (void); - - int handle_timeout (const ACE_Time_Value ¤t_time, - const void *act); -}; - -int -Deadlock::svc (void) -{ - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Deadlock starts accessing Reactor and Timer Queue....\n"))); - - this->reactor ()->schedule_timer (this, - 0, - ACE_Time_Value (1)); - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Deadlock completes accessing Reactor and Timer Queue....\n"))); - - return 0; -} - -int -Deadlock::handle_timeout (const ACE_Time_Value &, - const void *) -{ - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Deadlock timeout\n"))); - - return 0; -} - -class Event_Handler : public ACE_Event_Handler -{ -public: - - Event_Handler (Deadlock &deadlock); - - int handle_timeout (const ACE_Time_Value ¤t_time, - const void *act); - - int handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask); - - Deadlock &deadlock_; -}; - -Event_Handler::Event_Handler (Deadlock &deadlock) - : deadlock_ (deadlock) -{ -} - -int -Event_Handler::handle_timeout (const ACE_Time_Value &, - const void *) -{ - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Event_Handler timeout\n"))); - - return -1; -} - -int -Event_Handler::handle_close (ACE_HANDLE, - ACE_Reactor_Mask) -{ - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Event_Handler closed\n"))); - - // Activate Deadlock. - this->deadlock_.activate (); - - // Give Deadlock a chance to deadlock... ;-) - ACE_OS::sleep (1); - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Event Handler starts accessing Reactor....\n"))); - - // This is a superfluous call to the Reactor to acquire its lock. - this->reactor ()->max_notify_iterations (); - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Event Handler completes accessing Reactor....\n"))); - - return 0; -} - -int -run_main (int, ACE_TCHAR *[]) -{ - ACE_START_TEST (ACE_TEXT ("Timer_Cancellation_Test")); - - ACE_Reactor reactor (new ACE_TP_Reactor, - 1); - - Deadlock deadlock; - deadlock.reactor (&reactor); - - Event_Handler handler (deadlock); - - // Scheduler a timer to kick things off. - reactor.schedule_timer (&handler, - 0, - ACE_Time_Value (1)); - - // Run the event loop for a while. - ACE_Time_Value timeout (4); - reactor.run_reactor_event_loop (timeout); - - ACE_END_TEST; - - return 0; -} - -#else /* ACE_HAS_THREADS */ - -int -run_main (int, ACE_TCHAR *[]) -{ - ACE_START_TEST (ACE_TEXT ("Timer_Cancellation_Test")); - - ACE_ERROR ((LM_INFO, - ACE_TEXT ("threads not supported on this platform\n"))); - - ACE_END_TEST; - - return 0; -} - -#endif /* ACE_HAS_THREADS */ |