diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-01-08 03:54:17 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-01-08 03:54:17 +0000 |
commit | b38f08988b49429e3fcfc1ef648c8e96292dffed (patch) | |
tree | 8519dff27870a264c4a05ce625efd915e1d2ec0b /examples | |
parent | fe2521ea2374956a7bda4b1c4e62ef26cbeb7579 (diff) | |
download | ATCD-b38f08988b49429e3fcfc1ef648c8e96292dffed.tar.gz |
foo
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Reactor/Misc/notification.cpp | 50 | ||||
-rw-r--r-- | examples/Reactor/Misc/test_reactors.cpp | 4 |
2 files changed, 32 insertions, 22 deletions
diff --git a/examples/Reactor/Misc/notification.cpp b/examples/Reactor/Misc/notification.cpp index 28e457b084f..b392fa1d86a 100644 --- a/examples/Reactor/Misc/notification.cpp +++ b/examples/Reactor/Misc/notification.cpp @@ -49,7 +49,7 @@ private: size_t id_; // ID passed in by Thread_Handler constructor. - sig_atomic_t shutdown_; + static sig_atomic_t shutdown_; // Shutting down. // = Timing variables. @@ -60,6 +60,9 @@ private: static ACE_Time_Value interval_; }; +// Shutdown flag. +sig_atomic_t Thread_Handler::shutdown_ = 0; + // Delay factor for timer-driven I/O. ACE_Time_Value Thread_Handler::delay_; @@ -69,7 +72,6 @@ ACE_Time_Value Thread_Handler::interval_; Thread_Handler::Thread_Handler (int delay, int interval, int n_threads) - : shutdown_ (0) { delay_.set (delay); interval_.set (interval); @@ -110,23 +112,6 @@ Thread_Handler::Thread_Handler (int delay, ACE_Thread::sigsetmask (SIG_UNBLOCK, sig_set); } -// Test stdin handling (can use select to demultiplex HANDLEs) - -int -Thread_Handler::handle_input (ACE_HANDLE handle) -{ - char buf[BUFSIZ]; - ssize_t n = ACE_OS::read (handle, buf, sizeof buf); - - if (n > 0) - { - ACE_DEBUG ((LM_DEBUG, "(%t) %*s", n, buf)); - return this->notify (); - } - else - return -1; -} - int Thread_Handler::notify (ACE_Time_Value *timeout) { @@ -144,6 +129,29 @@ Thread_Handler::notify (ACE_Time_Value *timeout) return 0; } +// Test stdin handling (can use select to demultiplex HANDLEs) + +int +Thread_Handler::handle_input (ACE_HANDLE handle) +{ + char buf[BUFSIZ]; + ssize_t n = ACE_OS::read (handle, buf, sizeof buf); + + if (n > 0) + { + ACE_DEBUG ((LM_DEBUG, "(%t) %*s", n, buf)); + + // Only wait up to 10 milliseconds to notify the Reactor. + ACE_Time_Value timeout (0, 10 * 1000); + + if (this->notify (&timeout) == -1) + ACE_ERROR ((LM_DEBUG, "(%t), %p\n", "notify")); + return 0; + } + else + return -1; +} + // Perform a task that will test the ACE_Reactor's multi-threading // capabilities in separate threads. @@ -160,8 +168,10 @@ Thread_Handler::svc (void) ACE_Time_Value timeout (0, 10 * 1000); if (notify (&timeout) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "notify()")); + ACE_ERROR ((LM_ERROR, "(%t) %p\n", "notify")); } + + ACE_DEBUG ((LM_DEBUG, "(%t) exiting svc\n")); return 0; } diff --git a/examples/Reactor/Misc/test_reactors.cpp b/examples/Reactor/Misc/test_reactors.cpp index 834d6f5bf98..4910cf5fff4 100644 --- a/examples/Reactor/Misc/test_reactors.cpp +++ b/examples/Reactor/Misc/test_reactors.cpp @@ -140,10 +140,10 @@ worker (void *args) switch (reactor->handle_events (timeout)) { case -1: - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "reactor"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "reactor"), 0); /* NOTREACHED */ case 0: - ACE_ERROR_RETURN ((LM_ERROR, "timeout\n"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "(%t) timeout\n"), 0); /* NOTREACHED */ } |