diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-04-22 23:35:14 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-04-22 23:35:14 +0000 |
commit | 59a442052a50cb047ffbdc9d17b0c45eed0438ee (patch) | |
tree | d3337176364f3e574efe43c5294e6429417366b8 /examples/Reactor/WFMO_Reactor | |
parent | 2a7c5ad5fda8578367e31c25f7efe66e24d52e84 (diff) | |
download | ATCD-59a442052a50cb047ffbdc9d17b0c45eed0438ee.tar.gz |
ChangeLogTag: Mon Apr 22 18:33:20 2002 Irfan Pyarali <irfan@cs.wustl.edu>
Diffstat (limited to 'examples/Reactor/WFMO_Reactor')
-rw-r--r-- | examples/Reactor/WFMO_Reactor/Abandoned.dsp (renamed from examples/Reactor/WFMO_Reactor/Abondoned.dsp) | 12 | ||||
-rw-r--r-- | examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw | 2 | ||||
-rwxr-xr-x | examples/Reactor/WFMO_Reactor/run_test.pl | 62 | ||||
-rw-r--r-- | examples/Reactor/WFMO_Reactor/test_handle_close.cpp | 87 | ||||
-rw-r--r-- | examples/Reactor/WFMO_Reactor/test_multithreading.cpp | 1 | ||||
-rw-r--r-- | examples/Reactor/WFMO_Reactor/test_network_events.cpp | 9 | ||||
-rw-r--r-- | examples/Reactor/WFMO_Reactor/test_window_messages.cpp | 2 |
7 files changed, 128 insertions, 47 deletions
diff --git a/examples/Reactor/WFMO_Reactor/Abondoned.dsp b/examples/Reactor/WFMO_Reactor/Abandoned.dsp index d113db90ba6..8f57ae879c5 100644 --- a/examples/Reactor/WFMO_Reactor/Abondoned.dsp +++ b/examples/Reactor/WFMO_Reactor/Abandoned.dsp @@ -1,23 +1,23 @@ -# Microsoft Developer Studio Project File - Name="Abondoned" - Package Owner=<4>
+# Microsoft Developer Studio Project File - Name="Abandoned" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
-CFG=Abondoned - Win32 Debug
+CFG=Abandoned - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
-!MESSAGE NMAKE /f "Abondoned.mak".
+!MESSAGE NMAKE /f "Abandoned.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
-!MESSAGE NMAKE /f "Abondoned.mak" CFG="Abondoned - Win32 Debug"
+!MESSAGE NMAKE /f "Abandoned.mak" CFG="Abandoned - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
-!MESSAGE "Abondoned - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "Abandoned - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
@@ -49,7 +49,7 @@ LINK32=link.exe # ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\ace"
# Begin Target
-# Name "Abondoned - Win32 Debug"
+# Name "Abandoned - Win32 Debug"
# Begin Source File
SOURCE=.\test_abandoned.cpp
diff --git a/examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw b/examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw index 0e0f4c6988b..77aba17fb7f 100644 --- a/examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw +++ b/examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw @@ -15,7 +15,7 @@ Package=<4> ###############################################################################
-Project: "Abondoned"=.\Abondoned.dsp - Package Owner=<4>
+Project: "Abandoned"=.\Abandoned.dsp - Package Owner=<4>
Package=<5>
{{{
diff --git a/examples/Reactor/WFMO_Reactor/run_test.pl b/examples/Reactor/WFMO_Reactor/run_test.pl new file mode 100755 index 00000000000..574255ccf2f --- /dev/null +++ b/examples/Reactor/WFMO_Reactor/run_test.pl @@ -0,0 +1,62 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +require Process; +use lib '../../../bin'; +use PerlACE::Run_Test; + +# +# These tests only run on Win32 +# +if ($^O ne "MSWin32") +{ + exit; +} + +$test_timeout = 60; + +@tests = + ( + "Abandoned", + "Apc", +# "Console_Input", # This test is interactive + "Directory_Changes", + "Exceptions", + "Handle_Close", + "Multithreading", +# "Network_Events", # This test is interactive + "Prerun_State_Changes", + "Registration", + "Registry_Changes", + "Removals", + "Suspended_Removals", +# "Talker", # This test is interactive + "Timeouts", + "Window_Messages", + ); + +for $test (@tests) +{ + print STDERR "\n________________________________________\n"; + print STDERR "\nStarting test \"$test\""; + print STDERR "\n________________________________________\n\n"; + + $test_process = new PerlACE::Process ($test); + $test_process->Spawn (); + $test_result = $test_process->WaitKill ($test_timeout); + + if ($test_result != 0) + { + print STDERR "\n________________________________________\n"; + print STDERR "\nERROR: \"$test\" returned $test_result"; + print STDERR "\n________________________________________\n"; + } + + print STDERR "\n________________________________________\n"; + print STDERR "\n\"$test\" completed"; + print STDERR "\n________________________________________\n"; +} diff --git a/examples/Reactor/WFMO_Reactor/test_handle_close.cpp b/examples/Reactor/WFMO_Reactor/test_handle_close.cpp index 5141262c2a8..72a8ef29b2f 100644 --- a/examples/Reactor/WFMO_Reactor/test_handle_close.cpp +++ b/examples/Reactor/WFMO_Reactor/test_handle_close.cpp @@ -64,6 +64,11 @@ public: { } + ~Handler (void) + { + this->reactor (0); + } + ACE_HANDLE get_handle (void) const { return this->pipe_.read_handle (); @@ -93,8 +98,8 @@ public: // Optionally cancel reads if (cancel_reads) { - int result = ACE_Reactor::instance ()->cancel_wakeup (this, - ACE_Event_Handler::READ_MASK); + int result = this->reactor ()->cancel_wakeup (this, + ACE_Event_Handler::READ_MASK); ACE_ASSERT (result != -1); } @@ -119,6 +124,11 @@ public: { } + ~Different_Handler (void) + { + this->reactor (0); + } + ACE_HANDLE get_handle (void) const { return this->pipe_.read_handle (); @@ -138,8 +148,8 @@ public: ACE_DEBUG ((LM_DEBUG, "Different_Handler::handle_input\n")); // Remove for reading - int result = ACE_Reactor::instance ()->remove_handler (this, - ACE_Event_Handler::READ_MASK); + int result = this->reactor ()->remove_handler (this, + ACE_Event_Handler::READ_MASK); ACE_ASSERT (result == 0); return 0; @@ -150,9 +160,9 @@ public: ACE_DEBUG ((LM_DEBUG, "Different_Handler::handle_output\n")); // Add for reading - int result = ACE_Reactor::instance ()->mask_ops (this, - ACE_Event_Handler::READ_MASK, - ACE_Reactor::ADD_MASK); + int result = this->reactor ()->mask_ops (this, + ACE_Event_Handler::READ_MASK, + ACE_Reactor::ADD_MASK); ACE_ASSERT (result != -1); ACE_Reactor_Mask old_masks = @@ -163,9 +173,9 @@ public: ACE_static_cast (ACE_Reactor_Mask, result)); // Get new masks - result = ACE_Reactor::instance ()->mask_ops (this, - ACE_Event_Handler::NULL_MASK, - ACE_Reactor::GET_MASK); + result = this->reactor ()->mask_ops (this, + ACE_Event_Handler::NULL_MASK, + ACE_Reactor::GET_MASK); ACE_ASSERT (result != -1); ACE_Reactor_Mask current_masks = @@ -178,8 +188,8 @@ public: // Remove for writing ACE_Reactor_Mask mask = ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::DONT_CALL; - result = ACE_Reactor::instance ()->remove_handler (this, - mask); + result = this->reactor ()->remove_handler (this, + mask); ACE_ASSERT (result == 0); // Write to the pipe; this causes handle_input to get called. @@ -197,26 +207,42 @@ protected: // // Selection of which reactor should get created // -void +ACE_Reactor * create_reactor (void) { ACE_Reactor_Impl *impl = 0; + int delete_implementation = 0; if (opt_wfmo_reactor) { #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_NEW (impl, - ACE_WFMO_Reactor); + ACE_NEW_RETURN (impl, + ACE_WFMO_Reactor, + 0); + delete_implementation = 1; #endif /* ACE_WIN32 */ } else if (opt_select_reactor) - ACE_NEW (impl, - ACE_Select_Reactor); + { + ACE_NEW_RETURN (impl, + ACE_Select_Reactor, + 0); + delete_implementation = 1; + } + else + { + impl = + ACE_Reactor::instance ()->implementation (); + delete_implementation = 0; + } ACE_Reactor *reactor = 0; - ACE_NEW (reactor, - ACE_Reactor (impl)); - ACE_Reactor::instance (reactor); + ACE_NEW_RETURN (reactor, + ACE_Reactor (impl, + delete_implementation), + 0); + + return reactor; } int @@ -256,17 +282,8 @@ main (int argc, char *argv[]) Handler handler (pipe1); Different_Handler different_handler (pipe2); - // Create reactor - create_reactor (); - // Manage memory automagically. - auto_ptr<ACE_Reactor> reactor (ACE_Reactor::instance ()); - auto_ptr<ACE_Reactor_Impl> impl; - - // If we are using other that the default implementation, we must - // clean up. - if (opt_select_reactor || opt_wfmo_reactor) - impl = auto_ptr<ACE_Reactor_Impl> (ACE_Reactor::instance ()->implementation ()); + auto_ptr<ACE_Reactor> reactor (create_reactor ()); // Register handlers ACE_Reactor_Mask handler_mask = @@ -278,12 +295,12 @@ main (int argc, char *argv[]) ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::EXCEPT_MASK; - result = ACE_Reactor::instance ()->register_handler (&handler, - handler_mask); + result = reactor->register_handler (&handler, + handler_mask); ACE_ASSERT (result == 0); - result = ACE_Reactor::instance ()->register_handler (&different_handler, - different_handler_mask); + result = reactor->register_handler (&different_handler, + different_handler_mask); ACE_ASSERT (result == 0); // Write to the pipe; this causes handle_input to get called. @@ -298,7 +315,7 @@ main (int argc, char *argv[]) // Run for three seconds ACE_Time_Value time (3); - ACE_Reactor::instance ()->run_event_loop (time); + reactor->run_event_loop (time); ACE_DEBUG ((LM_DEBUG, "\nClosing down the application\n\n")); diff --git a/examples/Reactor/WFMO_Reactor/test_multithreading.cpp b/examples/Reactor/WFMO_Reactor/test_multithreading.cpp index ee368d18c11..023f6c02ec3 100644 --- a/examples/Reactor/WFMO_Reactor/test_multithreading.cpp +++ b/examples/Reactor/WFMO_Reactor/test_multithreading.cpp @@ -143,6 +143,7 @@ Task_Handler::Task_Handler (size_t number_of_handles, Task_Handler::~Task_Handler (void) { + this->reactor (0); delete [] this->events_; } diff --git a/examples/Reactor/WFMO_Reactor/test_network_events.cpp b/examples/Reactor/WFMO_Reactor/test_network_events.cpp index 3f3c7fdcd20..3a13487af7c 100644 --- a/examples/Reactor/WFMO_Reactor/test_network_events.cpp +++ b/examples/Reactor/WFMO_Reactor/test_network_events.cpp @@ -24,7 +24,7 @@ // // To run this example, start an instance of this example and // connect to it using telnet (to port -// ACE_DEFAULT_SERVER_PORT(10002)). +// ACE_DEFAULT_SERVER_PORT(20002)). // // = AUTHOR // Irfan Pyarali @@ -108,6 +108,9 @@ Network_Handler::handle_close (ACE_HANDLE handle, this->stream_.close (); delete this; + + ACE_Reactor::end_event_loop (); + return 0; } @@ -140,9 +143,6 @@ Network_Listener::Network_Listener (void) Network_Listener::~Network_Listener (void) { - this->reactor ()->remove_handler (this, ACE_Event_Handler::ACCEPT_MASK || - ACE_Event_Handler::DONT_CALL); - this->handle_close (this->get_handle (), ACE_Event_Handler::ALL_EVENTS_MASK); } ACE_HANDLE @@ -189,6 +189,7 @@ Network_Listener::handle_close (ACE_HANDLE handle, ACE_DEBUG ((LM_DEBUG, "Network_Listener::handle_close handle = %d\n", handle)); this->acceptor_.close (); + return 0; } diff --git a/examples/Reactor/WFMO_Reactor/test_window_messages.cpp b/examples/Reactor/WFMO_Reactor/test_window_messages.cpp index f46dea7ad19..93ea3b91e4d 100644 --- a/examples/Reactor/WFMO_Reactor/test_window_messages.cpp +++ b/examples/Reactor/WFMO_Reactor/test_window_messages.cpp @@ -53,7 +53,7 @@ timer_callback (HWND hwnd, UINT idEvent, DWORD dwTime) { - ACE_DEBUG ((LM_DEBUG, "(%t) timeout occured @ %d\n", dwTime)); + ACE_DEBUG ((LM_DEBUG, "(%t) timeout occured @ %u\n", dwTime)); global_event_handler->handle_.signal (); } |