diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-02-17 01:02:17 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-02-17 01:02:17 +0000 |
commit | 83379a56bcf820a1b7b9974ec89c59915f1816d8 (patch) | |
tree | db2393337b28f0d06437fd2da365060a11a2e112 /examples | |
parent | c685695d30d92cc376ab180641e5faf73cd2b8c1 (diff) | |
download | ATCD-83379a56bcf820a1b7b9974ec89c59915f1816d8.tar.gz |
foo
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Reactor/Misc/test_signals_1.cpp | 23 | ||||
-rw-r--r-- | examples/Reactor/ReactorEx/test_MT.cpp | 15 | ||||
-rw-r--r-- | examples/Reactor/WFMO_Reactor/test_MT.cpp | 15 |
3 files changed, 35 insertions, 18 deletions
diff --git a/examples/Reactor/Misc/test_signals_1.cpp b/examples/Reactor/Misc/test_signals_1.cpp index 710c07a3eff..fcb7ba8d05f 100644 --- a/examples/Reactor/Misc/test_signals_1.cpp +++ b/examples/Reactor/Misc/test_signals_1.cpp @@ -1,5 +1,13 @@ +// This simple program illustrates the difference between handling +// signals via the Reactor (which doesn't cause the event loop to +// terminate) and signals that aren't handled via the Reactor (which +// do). + #include "ace/Service_Config.h" +// Number of times to allow signal to execute until we quit. +static size_t count = 10; + static void my_signal_function (int sig) { @@ -13,7 +21,14 @@ public: siginfo_t *, ucontext_t *) { - ACE_DEBUG ((LM_DEBUG, "Executed ACE signal handler for sig %S\n", sig)); + ACE_DEBUG ((LM_DEBUG, "Executed ACE signal handler for sig %S, count = %d\n", + sig, count)); + + count--; + + if (count == 0) + ACE_Service_Config::end_reactor_event_loop (); + return 0; } @@ -54,10 +69,10 @@ main (int, char *argv[]) // This just executes the reactor events until my_handler tells us // we are finished. - ACE_DEBUG ((LM_DEBUG, "starting event loop\n")); + ACE_DEBUG ((LM_DEBUG, "starting event loop that runs until you've typed ^C a total of 10 times or ^\\ once.\n")); - int result = my_config.run_reactor_event_loop (); + while (my_config.reactor_event_loop_done () == 0) + my_config.run_reactor_event_loop (); - ACE_DEBUG ((LM_DEBUG, "result = %d\n", result)); return 0; } diff --git a/examples/Reactor/ReactorEx/test_MT.cpp b/examples/Reactor/ReactorEx/test_MT.cpp index 6a7975c67dc..f3c910705bc 100644 --- a/examples/Reactor/ReactorEx/test_MT.cpp +++ b/examples/Reactor/ReactorEx/test_MT.cpp @@ -66,8 +66,8 @@ parse_args (int argc, char **argv) class Task_Handler : public ACE_Task<ACE_NULL_SYNCH> { public: - Task_Handler (int number_of_handles, - int concurrent_threads); + Task_Handler (size_t number_of_handles, + size_t concurrent_threads); // Constructor. ~Task_Handler (void); @@ -79,7 +79,7 @@ public: int svc (void); // Task event loop. - int signal (int index); + int signal (size_t index); // Signal an event. private: @@ -96,11 +96,12 @@ Task_Handler::svc (void) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "handle_events"), 0); } -Task_Handler::Task_Handler (int number_of_handles, - int concurrent_threads) +Task_Handler::Task_Handler (size_t number_of_handles, + size_t int concurrent_threads) { ACE_NEW (this->events_, ACE_Auto_Event [number_of_handles]); - for (int i = 0; i < number_of_handles; i++) + + for (size_t i = 0; i < number_of_handles; i++) { if (ACE_Service_Config::reactorEx ()->register_handler (this, this->events_[i].handle ()) == -1) @@ -144,7 +145,7 @@ Task_Handler::handle_signal (int signum, siginfo_t *siginfo, ucontext_t *) } int -Task_Handler::signal (int index) +Task_Handler::signal (size_T index) { return this->events_[index].signal (); } diff --git a/examples/Reactor/WFMO_Reactor/test_MT.cpp b/examples/Reactor/WFMO_Reactor/test_MT.cpp index 6a7975c67dc..f3c910705bc 100644 --- a/examples/Reactor/WFMO_Reactor/test_MT.cpp +++ b/examples/Reactor/WFMO_Reactor/test_MT.cpp @@ -66,8 +66,8 @@ parse_args (int argc, char **argv) class Task_Handler : public ACE_Task<ACE_NULL_SYNCH> { public: - Task_Handler (int number_of_handles, - int concurrent_threads); + Task_Handler (size_t number_of_handles, + size_t concurrent_threads); // Constructor. ~Task_Handler (void); @@ -79,7 +79,7 @@ public: int svc (void); // Task event loop. - int signal (int index); + int signal (size_t index); // Signal an event. private: @@ -96,11 +96,12 @@ Task_Handler::svc (void) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "handle_events"), 0); } -Task_Handler::Task_Handler (int number_of_handles, - int concurrent_threads) +Task_Handler::Task_Handler (size_t number_of_handles, + size_t int concurrent_threads) { ACE_NEW (this->events_, ACE_Auto_Event [number_of_handles]); - for (int i = 0; i < number_of_handles; i++) + + for (size_t i = 0; i < number_of_handles; i++) { if (ACE_Service_Config::reactorEx ()->register_handler (this, this->events_[i].handle ()) == -1) @@ -144,7 +145,7 @@ Task_Handler::handle_signal (int signum, siginfo_t *siginfo, ucontext_t *) } int -Task_Handler::signal (int index) +Task_Handler::signal (size_T index) { return this->events_[index].signal (); } |