summaryrefslogtreecommitdiff
path: root/examples/Reactor
diff options
context:
space:
mode:
Diffstat (limited to 'examples/Reactor')
-rw-r--r--examples/Reactor/Misc/Makefile4
-rw-r--r--examples/Reactor/Misc/signal_tester.cpp221
-rw-r--r--examples/Reactor/Misc/test_signals.cpp226
-rw-r--r--examples/Reactor/Proactor/Aio_Platform_Test_C.cpp137
-rw-r--r--examples/Reactor/Proactor/Makefile5
-rw-r--r--examples/Reactor/Proactor/README56
-rw-r--r--examples/Reactor/Proactor/post_completion.dsp90
-rw-r--r--examples/Reactor/Proactor/post_completions.cpp291
-rw-r--r--examples/Reactor/Proactor/simple_test_proactor.cpp260
-rw-r--r--examples/Reactor/Proactor/test_aiocb.cpp10
-rw-r--r--examples/Reactor/Proactor/test_aiocb_ace.cpp255
-rw-r--r--examples/Reactor/Proactor/test_aiosig.cpp76
-rw-r--r--examples/Reactor/Proactor/test_aiosig_ace.cpp73
-rw-r--r--examples/Reactor/Proactor/test_end_event_loop.cpp170
-rw-r--r--examples/Reactor/Proactor/test_end_event_loop.dsp90
-rw-r--r--examples/Reactor/Proactor/test_proactor.cpp32
-rw-r--r--examples/Reactor/Proactor/test_proactor.dsw24
-rw-r--r--examples/Reactor/Proactor/test_timeout.cpp59
-rw-r--r--examples/Reactor/Proactor/test_timeout_st.cpp98
19 files changed, 113 insertions, 2064 deletions
diff --git a/examples/Reactor/Misc/Makefile b/examples/Reactor/Misc/Makefile
index 6217f6639c9..9f7880fd03f 100644
--- a/examples/Reactor/Misc/Makefile
+++ b/examples/Reactor/Misc/Makefile
@@ -322,7 +322,9 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
$(ACE_ROOT)/ace/SString.i \
$(ACE_ROOT)/ace/Malloc_Base.h \
$(ACE_ROOT)/ace/Log_Record.i \
- $(ACE_ROOT)/ace/Event_Handler.i
+ $(ACE_ROOT)/ace/Event_Handler.i \
+ $(ACE_ROOT)/ace/Event_Handler_T.i \
+ $(ACE_ROOT)/ace/Event_Handler_T.cpp
.obj/test_reactors.o .obj/test_reactors.so .shobj/test_reactors.o .shobj/test_reactors.so: test_reactors.cpp \
$(ACE_ROOT)/ace/Reactor.h \
$(ACE_ROOT)/ace/Handle_Set.h \
diff --git a/examples/Reactor/Misc/signal_tester.cpp b/examples/Reactor/Misc/signal_tester.cpp
deleted file mode 100644
index 37613f14f38..00000000000
--- a/examples/Reactor/Misc/signal_tester.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-// Perform an extensive test of the ACE_Reactor's event dispatching
-// $Id$
-
-// mechanisms. These mechanisms illustrate how signals, I/O, and
-// timeout events can all be handled within the same framework. In
-// addition, this example illustrates how to use the ACE_Reactor for
-// devices that perform I/O via signals (such as SVR4 message queues).
-
-
-#include "ace/Service_Config.h"
-
-// Used to shut down the event loop.
-static sig_atomic_t done = 0;
-
-// This class illustrates how to handle signal-driven I/O using the
-// ACE_Reactor framework. Note that signals may be caught and
-// processed without requiring the use of global signal handler
-// functions or global signal handler data.
-
-class Sig_Handler : public ACE_Event_Handler
-{
-public:
- Sig_Handler (void);
- virtual ACE_HANDLE get_handle (void) const;
- virtual int handle_input (ACE_HANDLE);
- virtual int shutdown (ACE_HANDLE, ACE_Reactor_Mask);
- virtual int handle_signal (ACE_HANDLE signum, siginfo_t * = 0,
- ucontext_t * = 0);
-
-private:
- ACE_HANDLE handle_;
-};
-
-// A dummy_handle is required to reserve a slot in the ACE_Reactor's
-// descriptor table.
-
-Sig_Handler::Sig_Handler (void)
-{
- // Assign the Sig_Handler a dummy I/O descriptor. Note that even
- // though we open this file "Write Only" we still need to use the
- // ACE_Event_Handler::NULL_MASK when registering this with the
- // ACE_Reactor (see below).
- this->handle_ = ACE_OS::open (ACE_DEV_NULL, O_WRONLY);
- ACE_ASSERT (this->handle_ != -1);
-
- // Register signal handler object. Note that NULL_MASK is used to
- // keep the ACE_Reactor from calling us back on the "/dev/null"
- // descriptor.
- if (ACE_Service_Config::reactor ()->register_handler
- (this, ACE_Event_Handler::NULL_MASK) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n%a", "register_handler", 1));
-
- // Create a sigset_t corresponding to the signals we want to catch.
- ACE_Sig_Set sig_set;
-
- sig_set.sig_add (SIGINT);
- sig_set.sig_add (SIGQUIT);
- sig_set.sig_add (SIGALRM);
-
- // Register the signal handler object to catch the signals.
- if (ACE_Service_Config::reactor ()->register_handler (sig_set, this) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n%a", "register_handler", 1));
-}
-
-// Called by the ACE_Reactor to extract the fd.
-
-ACE_HANDLE
-Sig_Handler::get_handle (void) const
-{
- return this->handle_;
-}
-
-// In a real application, this method would be where the read on the
-// signal-driven I/O device would occur asynchronously. For now we'll
-// just print a greeting to let you know that everything is working
-// properly!
-
-int
-Sig_Handler::handle_input (ACE_HANDLE)
-{
- ACE_DEBUG ((LM_DEBUG, "handling asynchonrous input...\n"));
- return 0;
-}
-
-// In a real application, this method would do any cleanup activities
-// required when shutting down the I/O device.
-
-int
-Sig_Handler::shutdown (ACE_HANDLE, ACE_Reactor_Mask)
-{
- ACE_DEBUG ((LM_DEBUG, "closing down Sig_Handler...\n"));
- return 0;
-}
-
-// This method handles all the signals that are being caught by this
-// object. In our simple example, we are simply catching SIGALRM,
-// SIGINT, and SIGQUIT. Anything else is logged and ignored.
-//
-// There are several advantages to using this approach. First,
-// the behavior triggered by the signal is handled in the main event
-// loop, rather than in the signal handler. Second, the ACE_Reactor's
-// signal handling mechanism eliminates the need to use global signal
-// handler functions and data.
-
-int
-Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *)
-{
- ACE_DEBUG ((LM_DEBUG, "received signal %S\n", signum));
-
- switch (signum)
- {
- case SIGALRM:
- // Rearm the alarm.
- ACE_OS::alarm (4);
- break;
- case SIGINT:
- // Tell the ACE_Reactor to enable the ready bit for
- // this->handle_. The ACE_Reactor will subsequently call the
- // Sig_Handler::handle_input method from within its event loop.
- return ACE_Service_Config::reactor ()->ready_ops
- (this->handle_, ACE_Event_Handler::READ_MASK, ACE_Reactor::ADD_MASK);
- case SIGQUIT:
- ACE_DEBUG ((LM_DEBUG, "%S: shutting down signal tester\n", signum));
- ACE_Service_Config::end_reactor_event_loop ();
- break;
- default:
- ACE_DEBUG ((LM_DEBUG,
- "%S: not handled, returning to program\n", signum));
- break;
- }
- return 0;
-}
-
-// This class illustrates that the ACE_Reactor can handle signals,
-// STDIO, and timeouts using the same mechanisms.
-
-class STDIN_Handler : public ACE_Event_Handler
-{
-public:
- STDIN_Handler (void);
- virtual int handle_input (ACE_HANDLE);
- virtual int handle_timeout (const ACE_Time_Value &,
- const void *arg);
-};
-
-STDIN_Handler::STDIN_Handler (void)
-{
- if (ACE::register_stdin_handler (this,
- ACE_Service_Config::reactor (),
- ACE_Service_Config::thr_mgr ()) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n", "register_stdin_handler"));
-
- // Register the STDIN_Handler to be dispatched once every second.
- else if (ACE_Service_Config::reactor ()->schedule_timer
- (this, 0, ACE_Time_Value (1), ACE_Time_Value (1)) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n%a", "schedule_timer", 1));
-}
-
-int
-STDIN_Handler::handle_timeout (const ACE_Time_Value &tv,
- const void *)
-{
- ACE_DEBUG ((LM_DEBUG, "timeout occurred at %d sec, %d usec\n",
- tv.sec (), tv.usec ()));
- return 0;
-}
-
-// Read from input descriptor and write to stdout descriptor.
-
-int
-STDIN_Handler::handle_input (ACE_HANDLE handle)
-{
- ssize_t n;
- char buf[BUFSIZ];
-
- switch (n = ACE_OS::read (handle, buf, sizeof buf))
- {
- case -1:
- if (errno == EINTR)
- return 0;
- /* NOTREACHED */
- else
- ACE_ERROR ((LM_ERROR, "%p\n", "read"));
- /* FALLTHROUGH */
- case 0:
- ACE_Service_Config::end_reactor_event_loop ();
- break;
- default:
- {
- ssize_t result = ACE::write_n (ACE_STDOUT, buf, n);
-
- if (result != n)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write"),
- result == -1 && errno == EINTR ? 0 : -1);
- }
- }
- return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
- ACE_Service_Config daemon (argv [0]);
-
- // Signal handler.
- Sig_Handler sh;
-
- // Define an I/O handler object.
- STDIN_Handler ioh;
-
- // Optionally start the alarm.
- if (argc > 1)
- ACE_OS::alarm (4);
-
- // Loop handling signals and I/O events until SIGQUIT occurs.
-
- while (daemon.reactor_event_loop_done () == 0)
- daemon.run_reactor_event_loop ();
-
- return 0;
-}
diff --git a/examples/Reactor/Misc/test_signals.cpp b/examples/Reactor/Misc/test_signals.cpp
deleted file mode 100644
index 6493667de12..00000000000
--- a/examples/Reactor/Misc/test_signals.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-// Test the ability of the Reactor/Signal_Handler to register multiple
-// $Id$
-
-// handler per-signal.
-
-/* This test works as follows:
-
- 1. To test the "original" semantics of ACE (i.e., only one
- ACE_Event_Handler can be registered per signal), you don't
- need to do anything special. Existing programs work the
- same since giving the Reactor's constructor a 0 value
- (which is the default argument, BTW) instructs it to behave
- as before. When a 0 is given, the ACE_Reactor's
- constructor/open method creates an instance of
- ACE_Sig_Handler and assigns this to an internal pointer.
- This pointer is then used to dispatch all signal-related
- methods within the Reactor. The default ACE_Sig_Handler
- only allows *one* ACE_Event_Handler to be registered
- per-signal.
-
- To run this version of the test do the following:
-
- % ./test-signal
- ./test_signals
- waiting for SIGINT or SIGQUIT
- ^C
- signal Interrupt occurred in Sig_Handler_2 (fruity, 0, 0) with count = 1
- waiting for SIGINT or SIGQUIT
- ^\
- signal Quit occurred in Sig_Handler_2 (fruity, 0, 0) with count = 2
- shutting down SIGQUIT in Sig_Handler_2 (fruity, 0, 0)
- waiting for SIGINT or SIGQUIT
- ^C
- signal Interrupt occurred in Sig_Handler_2 (fruity, 0, 0) with count = 3
- waiting for SIGINT or SIGQUIT
- ^\Quit (core dumped)
-
- Note that in this test only one handler (the last one --
- "Sig_Handler_2 (fruity)") is actually registered. BTW, the
- core dump is the expected behavior since the default
- disposition is restored when there are no more handlers
- (see the code below).
-
- 2. To test the "multiple handlers per-signal semantics", you
- need to pass the constructor/open method of the ACE_Reactor
- a pointer to a an instance of ACE_Sig_Handlers (note the
- plural "s"). ACE_Sig_Handlers is a class that derives from
- ACE_Sig_Handler. The difference between these two classes
- is that (1) ACE_Sig_Handlers::register_signal allows
- multiple ACE_Event_Handlers to be registered per-signal and
- (2) it enables SA_RESTART by default. This class also
- implements Detlef Becker's algorithm for integrating ACE
- signal handling with 3rd party libraries.
-
- To run this version of the test do the following:
-
- % ./test_signals 1
-
- waiting for SIGINT or SIGQUIT
- ^C
- signal Interrupt occurred in external handler!
- signal Interrupt occurred in Sig_Handler_1 (howdy, 3, 1) with count = 1
- shutting down SIGINT in Sig_Handler_1 (howdy, 3, 1)
- signal Interrupt occurred in Sig_Handler_1 (doody, 5, 4) with count = 1
- shutting down SIGINT in Sig_Handler_1 (doody, 5, 4)
- signal Interrupt occurred in Sig_Handler_2 (tutty, 7, 6) with count = 1
- signal Interrupt occurred in Sig_Handler_2 (fruity, 9, 8) with count = 1
- waiting for SIGINT or SIGQUIT
- ^\
- signal Quit occurred in Sig_Handler_1 (howdy, 3, 1) with count = 2
- shutting down SIGQUIT in Sig_Handler_1 (howdy, 3, 1)
- signal Quit occurred in Sig_Handler_1 (doody, 5, 4) with count = 2
- shutting down SIGQUIT in Sig_Handler_1 (doody, 5, 4)
- signal Quit occurred in Sig_Handler_2 (tutty, 7, 6) with count = 2
- shutting down SIGQUIT in Sig_Handler_2 (tutty, 7, 6)
- signal Quit occurred in Sig_Handler_2 (fruity, 9, 8) with count = 2
- shutting down SIGQUIT in Sig_Handler_2 (fruity, 9, 8)
- waiting for SIGINT or SIGQUIT
- ^C
- signal Interrupt occurred in external handler!
- signal Interrupt occurred in Sig_Handler_2 (tutty, 7, 6) with count = 3
- signal Interrupt occurred in Sig_Handler_2 (fruity, 9, 8) with count = 3
- waiting for SIGINT or SIGQUIT
- ^\Quit (core dumped)
-
- When this test begins all four handlers are registered and
- dispatched when a SIGINT or SIGQUIT occurs. After the
- first SIGINT, the handle_signal method of the Sig_Handler_1
- objects unregister themselves. At that point there are 4
- SIGQUIT handlers left, but only 2 of our SIGINT handlers
- left (and the 1 external handler). After the first
- SIGQUIT, there are no SIGQUIT handlers left since they all
- deregister themselves (which restores the "SIG_DFL"
- disposition). On the second SIGINT there are only 3
- handlers left (2 of ours and 1 external). Finally, on the
- second SIGQUIT we exit and dump core since that's what
- happens with the default disposition for SIGQUIT. */
-
-#include "ace/Log_Msg.h"
-#include "ace/Reactor.h"
-
-class Sig_Handler_1 : public ACE_Event_Handler
-{
-public:
- Sig_Handler_1 (ACE_Reactor &reactor, char *msg)
- : msg_ (msg),
- count_ (0),
- reactor_ (reactor)
- {
- // Register the signal handlers.
- this->quit_sigkey_ = reactor.register_handler (SIGQUIT, this);
- this->int_sigkey_ = reactor.register_handler (SIGINT, this);
-
- if (this->quit_sigkey_ == -1 || this->int_sigkey_ == -1)
- ACE_ERROR ((LM_ERROR, "%p\n", "register_handler"));
- }
-
- virtual int handle_signal (int signum, siginfo_t *, ucontext_t *)
- {
- this->count_++;
- ACE_DEBUG ((LM_DEBUG,
- "\nsignal %S occurred in Sig_Handler_1 (%s, %d, %d) with count = %d",
- signum, this->msg_, this->int_sigkey_, this->quit_sigkey_, this->count_));
- if (this->count_ != 1 && signum == SIGQUIT)
- {
- if (this->reactor_.remove_handler (SIGQUIT, 0, 0,
- this->quit_sigkey_) == -1)
- ACE_ERROR ((LM_ERROR, "\n%p", "remove_handler"));
- else
- ACE_DEBUG ((LM_DEBUG, "\nshutting down SIGQUIT in Sig_Handler_1 (%s, %d, %d)",
- this->msg_, this->int_sigkey_, this->quit_sigkey_));
- }
- else if (this->count_ != 2 && signum == SIGINT)
- {
- if (this->reactor_.remove_handler (SIGINT, 0, 0,
- this->int_sigkey_) == -1)
- ACE_ERROR ((LM_ERROR, "\n%p", "remove_handler"));
- else
- ACE_DEBUG ((LM_DEBUG, "\nshutting down SIGINT in Sig_Handler_1 (%s, %d, %d)",
- this->msg_, this->int_sigkey_, this->quit_sigkey_));
- }
- return 0;
- }
-
-protected:
- char *msg_;
- int count_;
- int int_sigkey_;
- int quit_sigkey_;
- ACE_Reactor &reactor_;
-};
-
-class Sig_Handler_2 : public Sig_Handler_1
-{
-public:
- Sig_Handler_2 (ACE_Reactor &reactor, char *msg)
- : Sig_Handler_1 (reactor, msg)
- {
- }
-
- virtual int handle_signal (int signum, siginfo_t *, ucontext_t *)
- {
- this->count_++;
- ACE_DEBUG ((LM_DEBUG,
- "\nsignal %S occurred in Sig_Handler_2 (%s, %d, %d) with count = %d",
- signum, this->msg_, this->int_sigkey_, this->quit_sigkey_, this->count_));
- if (this->count_ != 0 && signum == SIGQUIT)
- {
- if (this->reactor_.remove_handler (SIGQUIT, 0, 0,
- this->quit_sigkey_) == -1)
- ACE_ERROR ((LM_ERROR, "\n%p", "remove_handler"));
- else
- ACE_DEBUG ((LM_DEBUG, "\nshutting down SIGQUIT in Sig_Handler_2 (%s, %d, %d)",
- this->msg_, this->int_sigkey_, this->quit_sigkey_));
- }
- else
- return 0;
- }
-};
-
-static void
-external_handler (int signum)
-{
- ACE_DEBUG ((LM_DEBUG, "\nsignal %S occurred in external handler!", signum));
-}
-
-#if !defined (HPUX)
-int
-main (int argc, char *argv)
-{
- // If argc > 1 then allow multiple handlers per-signal, else just
- // allow 1 handler per-signal.
- ACE_Sig_Handlers multi_handlers;
-
- ACE_Reactor reactor (argc > 1 ? &multi_handlers: 0);
-
- if (argc > 1)
- {
- // Register an "external" signal handler so that the
- // ACE_Sig_Handlers code will have something to incorporate!
- ACE_SignalHandler eh = ACE_SignalHandler (external_handler);
- ACE_Sig_Action sa (eh);
-
- sa.register_action (SIGINT);
- }
-
- // Create a bevy of handlers.
- Sig_Handler_1 h1 (reactor, "howdy"), h2 (reactor, "doody");
- Sig_Handler_2 h3 (reactor, "tutty"), h4 (reactor, "fruity");
-
- // Wait for user to type SIGINT and SIGQUIT.
-
- for (;;)
- {
- ACE_DEBUG ((LM_DEBUG, "\nwaiting for SIGINT or SIGQUIT\n"));
- reactor.handle_events ();
- }
- return 0;
-}
-#else
-int
-main (void)
-{
- ACE_ERROR_RETURN ((LM_ERROR, "The HP C++ compiler is too lame to support this feature\n"), -1);
-}
-#endif /* HPUX */
diff --git a/examples/Reactor/Proactor/Aio_Platform_Test_C.cpp b/examples/Reactor/Proactor/Aio_Platform_Test_C.cpp
deleted file mode 100644
index be720fdef40..00000000000
--- a/examples/Reactor/Proactor/Aio_Platform_Test_C.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-// $Id$
-// ============================================================================
-//
-// = FILENAME
-// aio_platform_test_c.cpp
-//
-// = DESCRITPTION
-// Testing the platform for POSIX Asynchronous I/O. This is the C
-// version of the $ACE_ROOT/tests/Aio_Platform_Test.cpp. Useful
-// to send bug reports.
-//
-// = AUTHOR
-// Programming for the Real World. Bill O. GallMeister.
-// Modified by Alexander Babu Arulanthu <alex@cs.wustl.edu>
-//
-// =====================================================================
-
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-
-#include <limits.h>
-
-#include <aio.h>
-
-int do_sysconf (void);
-int have_asynchio (void);
-
-static int file_handle = -1;
-char mb1 [BUFSIZ + 1];
-char mb2 [BUFSIZ + 1];
-aiocb aiocb1, aiocb2;
-sigset_t completion_signal;
-
-// For testing the <aio> stuff.
-int test_aio_calls (void);
-int issue_aio_calls (void);
-int query_aio_completions (void);
-int setup_signal_delivery (void);
-int do_sysconf (void);
-int have_asynchio (void);
-
-int
-do_sysconf (void)
-{
- // Call sysconf to find out runtime values.
- errno = 0;
-#if defined (_SC_LISTIO_AIO_MAX)
- printf ("Runtime value of LISTIO_AIO_MAX is %d, errno = %d\n",
- sysconf(_SC_LISTIO_AIO_MAX),
- errno);
-#else
- printf ("Runtime value of AIO_LISTIO_MAX is %d, errno = %d\n",
- sysconf(_SC_AIO_LISTIO_MAX),
- errno);
-#endif
-
- errno = 0;
- printf ("Runtime value of AIO_MAX is %d, errno = %d\n",
- sysconf (_SC_AIO_MAX),
- errno);
-
- errno = 0;
- printf ("Runtime value of _POSIX_ASYNCHRONOUS_IO is %d, errno = %d\n",
- sysconf (_SC_ASYNCHRONOUS_IO),
- errno);
-
- errno = 0;
- printf ("Runtime value of _POSIX_REALTIME_SIGNALS is %d, errno = %d\n",
- sysconf (_SC_REALTIME_SIGNALS),
- errno);
-
- errno = 0;
- printf ("Runtime value of RTSIG_MAX %d, Errno = %d\n",
- sysconf (_SC_RTSIG_MAX),
- errno);
-
- errno = 0;
- printf ("Runtime value of SIGQUEUE_MAX %d, Errno = %d\n",
- sysconf (_SC_SIGQUEUE_MAX),
- errno);
- return 0;
-}
-
-int
-have_asynchio (void)
-{
-#if defined (_POSIX_ASYNCHRONOUS_IO)
- // POSIX Asynch IO is present in this system.
-#if defined (_POSIX_ASYNC_IO)
- // If this is defined and it is not -1, POSIX_ASYNCH is supported
- // everywhere in the system.
-#if _POSIX_ASYNC_IO == -1
- printf ("_POSIX_ASYNC_IO = -1.. ASYNCH IO NOT supported at all\n");
- return -1;
-#else /* Not _POSIX_ASYNC_IO == -1 */
- printf ("_POSIX_ASYNC_IO = %d\n ASYNCH IO is supported FULLY\n",
- _POSIX_ASYNC_IO);
-#endif /* _POSIX_ASYNC_IO == -1 */
-
-#else /* Not defined _POSIX_ASYNC_IO */
- printf ("_POSIX_ASYNC_IO is not defined.\n");
- printf ("AIO might *not* be supported on some paths\n");
-#endif /* _POSIX_ASYNC_IO */
-
- // System defined POSIX Values.
- printf ("System claims to have POSIX_ASYNCHRONOUS_IO\n");
-
- printf ("_POSIX_AIO_LISTIO_MAX = %d\n", _POSIX_AIO_LISTIO_MAX);
- printf ("_POSIX_AIO_MAX = %d\n", _POSIX_AIO_MAX);
-
- // Check and print the run time values.
- do_sysconf ();
-
- return 0;
-
-#else /* Not _POSIX_ASYNCHRONOUS_IO */
- printf ("No support._POSIX_ASYNCHRONOUS_IO itself is not defined\n");
- return -1;
-#endif /* _POSIX_ASYNCHRONOUS_IO */
-}
-
-int
-main (int, char *[])
-{
- if (have_asynchio () == 0)
- printf ("Test successful\n");
- else
- printf ("Test not successful\n");
- return 0;
-}
diff --git a/examples/Reactor/Proactor/Makefile b/examples/Reactor/Proactor/Makefile
index c080b297abb..3932260c930 100644
--- a/examples/Reactor/Proactor/Makefile
+++ b/examples/Reactor/Proactor/Makefile
@@ -8,7 +8,10 @@
# Local macros
#----------------------------------------------------------------------------
-BIN = simple_test_proactor test_proactor test_aiosig_ace test_aiocb_ace test_timeout test_timeout_st post_completions test_end_event_loop
+BIN = test_proactor test_aiosig_ace
+LSRC = $(addsuffix .cpp,$(BIN))
+VLDLIBS = $(LDLIBS:%=%$(VAR))
+BUILD = $(VBIN)
#----------------------------------------------------------------------------
# Include macros and targets
diff --git a/examples/Reactor/Proactor/README b/examples/Reactor/Proactor/README
index 6509e3efcb4..fa873589773 100644
--- a/examples/Reactor/Proactor/README
+++ b/examples/Reactor/Proactor/README
@@ -1,10 +1,9 @@
-This README file lists all the example applications for the Proactor framework.
+This file describes the behavior of the POSIX <aio_> calls on the
+various platforms it is being tested on.
-Test/Example Applications for Proactor:
-=========================================
+Test Suits:
+==========
-The following tests are available.
-
o $ACE_ROOT/tests/Aio_Platform_Test.cpp : Tests basic limits
pertaining to the POSIX features
@@ -17,58 +16,23 @@ o $ACE_ROOT/examples/Reactor/Proactor/test_aiosig.cpp : This is a
C++ program for testing the Signal based completion approach
that uses <sigtimedwait> for completion querying.
-o $ACE_ROOT/examples/Reactor/Proactor/test_aiocb_ace.cpp: Portable
- version of test_aiocb.cpp. (Same as test_aiocb.cpp, but uses
- ACE_DEBUGs instead of printf's and ACE_Message_Blocks instead
- of char*'s.
-
-o $ACE_ROOT/examples/Reactor/Proactor/test_aiosig_ace.cpp: Portable
- version of test_aiosig.cpp. (Same as test_aiosig.cpp, but uses
- ACE_DEBUGs instead of printf's and ACE_Message_Blocks instead
- of char*'s.
+o $ACE_ROOT/examples/Reactor/Proactor/test_aiosig_ace.cpp: (Same as
+ test_aiosig.cpp, but uses ACE_DEBUGs instead of printf's and
+ ACE_Message_Blocks instead of char*'s.
o test_proactor.cpp (with ACE_POSIX_AIOCB_Proactor) : Test for
ACE_Proactor which uses AIOCB (AIO Control Blocks) based
- completions strategy Proactor. (#define
- ACE_POSIX_AIOCB_PROACTOR in the config file, but this is the
- default option)
+ completions strategy Proactor. (#define ACE_POSIX_AIOCB_PROACTOR)
o test_proactor.cpp (with ACE_POSIX_SIG_Proactor) : Test for
ACE_Proactor which uses real time signal based completion
- strategy proactor. (#define ACE_POSIX_SIG_PROACTOR in the
- config file)
-
-o test_multiple_loops.cpp : This example application shows how
- to write programs that combine the Proactor and Reactor event
- loops. This is possible only on WIN32 platform.
-
-o test_timeout.cpp : Multithreaded application testing the Timers
- mechanism of the Proactor.
-
-o test_timeout_st.cpp : Sinle threaded version of test_timeout.cpp.
+ strategy proactor. (#define ACE_POSIX_SIG_PROACTOR)
Behavior of POSIX AIO of various platforms:
==========================================
-
-
-Summary:
-======
- Sun Sun Lynx
- 5.6 5.7
-
-test_aiocb_ace Good Good Good
-(test_aiocb)
-
-test_aiosig_ace Inconst Inconst Inconst
-
-
-Inconst.: Inconsistent execution.
-
-
-
Aio_Platform_Test:
================
@@ -178,3 +142,5 @@ Lynx g++:
TO-DO : 1. Run <gdb> and watch for <errno> and figure when
it is changing over to 77.
+
+
diff --git a/examples/Reactor/Proactor/post_completion.dsp b/examples/Reactor/Proactor/post_completion.dsp
deleted file mode 100644
index b736965277c..00000000000
--- a/examples/Reactor/Proactor/post_completion.dsp
+++ /dev/null
@@ -1,90 +0,0 @@
-# Microsoft Developer Studio Project File - Name="post_completion" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=post_completion - 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 "post_completion.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 "post_completion.mak" CFG="post_completion - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "post_completion - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "post_completion - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "post_completion - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "post_completion - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /out:"post_completion.exe" /pdbtype:sept /libpath:"..\..\..\ace"
-
-!ENDIF
-
-# Begin Target
-
-# Name "post_completion - Win32 Release"
-# Name "post_completion - Win32 Debug"
-# Begin Source File
-
-SOURCE=..\post_completions.cpp
-# End Source File
-# End Target
-# End Project
diff --git a/examples/Reactor/Proactor/post_completions.cpp b/examples/Reactor/Proactor/post_completions.cpp
deleted file mode 100644
index 3c6eb8b0b56..00000000000
--- a/examples/Reactor/Proactor/post_completions.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-// $Id$
-// ============================================================================
-//
-// = FILENAME
-// post_completions.cpp
-//
-// = DESCRITPTION
-// This program demonstrates how to post fake completions to The
-// Proactor. It also shows the how to specify the particular
-// real-time signals to post completions. The Real-time signal
-// based completion strategy is implemented with
-// ACE_POSIX_SIG_PROACTOR.
-// (So, it can be used only if ACE_HAS_AIO_CALLS is defined and
-// ACE_POSIX_AIOCB_PROACTOR is not defined)
-// Since it is faking results, you have to pay by knowing and
-// using platform-specific implementation objects for Asynchronous
-// Result classes.
-// This example shows using an arbitrary result class for faking
-// completions. You can also use the predefined Result classes for
-// faking. The factory methods in the Proactor class create the
-// Result objects.
-//
-// = COMPILATION
-// make
-//
-// = RUN
-// ./post_completions
-//
-// = AUTHOR
-// Alexander Babu Arulanthu <alex@cs.wustl.edu>
-//
-// =====================================================================
-
-#include "ace/Proactor.h"
-#include "ace/Synch.h"
-#include "ace/Task.h"
-#include "ace/WIN32_Proactor.h"
-#include "ace/POSIX_Proactor.h"
-
-#if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || \
- (defined (ACE_HAS_AIO_CALLS)) && !defined (ACE_POSIX_AIOCB_PROACTOR))
-// This only works on Win32 platforms and on Unix platforms supporting
-// POSIX aio calls.
-
-#if defined (ACE_HAS_AIO_CALLS)
-#define RESULT_CLASS ACE_POSIX_Asynch_Result
-#elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
-#define RESULT_CLASS ACE_WIN32_Asynch_Result
-#endif /* ACE_HAS_AIO_CALLS */
-
-class ACE_Export My_Result : public RESULT_CLASS
-{
- // = TITLE
- //
- // Result Object that we will post to the Proactor.
- //
- // = DESCRIPTION
- //
-
-public:
- My_Result (ACE_Handler &handler,
- const void *act,
- int signal_number,
- size_t sequence_number)
- : RESULT_CLASS (handler,
- act,
- ACE_INVALID_HANDLE,
- 0, // Offset
- 0, // OffsetHigh
- 0, // Priority
- signal_number),
- sequence_number_ (sequence_number)
- {}
- // Constructor.
-
- virtual ~My_Result (void)
- {}
- // Destructor.
-
- void complete (u_long bytes_transferred,
- int success,
- const void *completion_key,
- u_long error)
- // This is the method that will be called by the Proactor for
- // dispatching the completion. This method generally calls one of
- // the call back hood methods defined in the ACE_Handler
- // class. But, we will just handle the completions here.
- {
- this->success_ = success;
- this->completion_key_ = completion_key;
- this->error_ = error;
-
- // Print the completion details.
- ACE_DEBUG ((LM_DEBUG,
- "(%t) Completion sequence number %d, success : %d, error : %d, signal_number : %d\n",
- this->sequence_number_,
- this->success_, this->error_, this->signal_number ()));
-
- // Sleep for a while.
- ACE_OS::sleep (4);
- }
-
-private:
- size_t sequence_number_;
- // Sequence number for the result object.
-};
-
-class ACE_Export My_Handler : public ACE_Handler
-{
- // = TITLE
- //
- // Handler class for faked completions.
- //
- // = DESCRIPTION
- //
-
-public:
- My_Handler (void) {}
- // Constructor.
-
- virtual ~My_Handler (void) {}
- // Destructor.
-
- // ACE_Atomic_Op <ACE_Thread_Mutex, int> completion_count_;
- // Count for the completion.
-};
-
-class ACE_Export My_Task: public ACE_Task <ACE_NULL_SYNCH>
-{
- // = TITLE
- //
- // Contains thread functions which execute event loops. Each
- // thread waits for a different signal.
- //
-public:
- My_Task (void) {}
- // Constructor.
-
- virtual ~My_Task (void) {}
- // Destructor.
-
- int open (void *proactor)
- {
- // Store the proactor.
- this->proactor_ = (ACE_Proactor *) proactor;
-
- // Activate the Task.
- this->activate (THR_NEW_LWP, 5);
-
- return 0;
- }
-
- int svc (void)
- {
- // Handle events for 13 seconds.
- ACE_Time_Value run_time (13);
-
- ACE_DEBUG ((LM_DEBUG, "(%t):Starting svc routine\n"));
-
- if (this->proactor_->handle_events (run_time) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "(%t):%p.\n", "Worker::svc"), -1);
-
- ACE_DEBUG ((LM_DEBUG, "(%t) work complete\n"));
-
- return 0;
- }
-
-private:
- ACE_Proactor *proactor_;
- // Proactor for this task.
-};
-
-int
-main (int argc, char *argv [])
-{
- ACE_DEBUG ((LM_DEBUG,
- "(%P | %t):Test starts \n"));
-
- // = Get two POSIX_SIG_Proactors, one with SIGRTMIN and one with
- // SIGRTMAX.
-
- ACE_Proactor proactor1;
- // Proactor1. SIGRTMIN Proactor. (default).
-
- // = Proactor2. SIGRTMAX Proactor.
-#if defined (ACE_HAS_AIO_CALLS) && !defined (ACE_POSIX_AIOCB_PROACTOR)
-
- ACE_DEBUG ((LM_DEBUG, "Using ACE_POSIX_SIG_Proactor\n"));
-
- sigset_t signal_set;
- // Signal set that we want to mask.
-
- // Clear the signal set.
- if (sigemptyset (&signal_set) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error:%p\n",
- "sigemptyset failed"),
- 1);
-
- // Add the SIGRTMAX to the signal set.
- if (sigaddset (&signal_set, ACE_SIGRTMAX) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error:%p\n",
- "sigaddset failed"),
- 1);
-
- // Make the POSIX Proactor.
- ACE_POSIX_SIG_Proactor posix_proactor (signal_set);
- // Get the Proactor interface out of it.
- ACE_Proactor proactor2 (&posix_proactor);
-#else /* ACE_HAS_AIO_CALLS && !ACE_POSIX_AIOCB_PROACTOR */
- ACE_Proactor proactor2;
-#endif /* ACE_HAS_AIO_CALLS && !ACE_POSIX_AIOCB_PROACTOR */
-
- // = Create Tasks. One pool of threads to handle completions on
- // SIGRTMIN and the other one to handle completions on SIGRTMAX.
- My_Task task1, task2;
- task1.open (&proactor1);
- task2.open (&proactor2);
-
- // Handler for completions.
- My_Handler handler;
-
- // = Create a few MyResult objects and post them to Proactor.
-
- My_Result *result_objects [10];
- int signal_number = ACE_SIGRTMAX;
- size_t ri;
-
- // Creation.
- for (ri = 0; ri < 10; ri++)
- {
- // Use RTMIN and RTMAX proactor alternatively, to post
- // completions.
- if (ri % 2)
- signal_number = ACE_SIGRTMIN;
- else
- signal_number = ACE_SIGRTMAX;
-
- // Create the result.
- ACE_NEW_RETURN (result_objects [ri],
- My_Result (handler,
- 0,
- signal_number,
- ri),
- 1);
- }
-
- // Post all the result objects.
- ACE_Proactor *proactor = &proactor2;
- for (ri = 0; ri < 10; ri++)
- {
- // Use RTMIN and RTMAX Proactor alternatively, to post
- // completions.
- if (ri % 2)
- proactor = &proactor1;
- else
- proactor = &proactor2;
-
- if (result_objects [ri]->post_completion (proactor->implementation ())
- == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Test failed\n"),
- 1);
- }
-
- ACE_Thread_Manager::instance ()->wait ();
-
- ACE_DEBUG ((LM_DEBUG,
- "(%P | %t):Test ends\n"));
- return 0;
-}
-
-#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Task <ACE_NULL_SYNCH>;
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Task <ACE_NULL_SYNCH>
-#endif /* ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA */
-
-#else /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS && !ACE_POSIX_AIOCB_PROACTOR*/
-
-int
-main (int, char *[])
-{
- ACE_DEBUG ((LM_DEBUG,
- "This example cannot work with AIOCB_Proactor.\n"));
- return 1;
-}
-
-#endif /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS && !ACE_POSIX_AIOCB_PROACTOR*/
-
diff --git a/examples/Reactor/Proactor/simple_test_proactor.cpp b/examples/Reactor/Proactor/simple_test_proactor.cpp
deleted file mode 100644
index b18b39a337a..00000000000
--- a/examples/Reactor/Proactor/simple_test_proactor.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// examples
-//
-// = FILENAME
-// simple_test_proactor.cpp
-//
-// = DESCRIPTION
-// Very simple version of test_proactor.cpp.
-//
-// = AUTHOR
-// Alexander Babu Arulanthu (alex@cs.wustl.edu)
-//
-// ============================================================================
-
-#include "ace/Service_Config.h"
-#include "ace/Proactor.h"
-#include "ace/Asynch_IO.h"
-#include "ace/Asynch_IO_Impl.h"
-#include "ace/Message_Block.h"
-#include "ace/Get_Opt.h"
-
-ACE_RCSID(Proactor, test_proactor, "$Id$")
-
-#if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS)))
- // This only works on Win32 platforms and on Unix platforms supporting
- // POSIX aio calls.
-
-static char *file = "simple_test_proactor.cpp";
-static char *dump_file = "simple_output";
-static int initial_read_size = BUFSIZ;
-static int done = 0;
-
-class Simple_Tester : public ACE_Handler
-{
- // = TITLE
- //
- // Simple_Tester
- //
- // = DESCRIPTION
- //
- // The class will be created by main(). This class reads a block
- // from the file and write that to the dump file.
-
-public:
- Simple_Tester (void);
- // Constructor.
-
- ~Simple_Tester (void);
-
- int open (void);
- // Open the operations and initiate read from the file.
-
-protected:
- // = These methods are called by the freamwork.
-
- virtual void handle_read_file (const ACE_Asynch_Read_File::Result &result);
- // This is called when asynchronous reads from the socket complete.
-
- virtual void handle_write_file (const ACE_Asynch_Write_File::Result &result);
- // This is called when asynchronous writes from the socket complete.
-
-private:
- int initiate_read_file (void);
-
- ACE_Asynch_Read_File rf_;
- // rf (read file): for writing from the file.
-
- ACE_Asynch_Write_File wf_;
- // ws (write File): for writing to the file.
-
- ACE_HANDLE input_file_;
- // File to read from.
-
- ACE_HANDLE dump_file_;
- // File for dumping data.
-
- // u_long file_offset_;
- // Current file offset
-
- // u_long file_size_;
- // File size
-};
-
-
-Simple_Tester::Simple_Tester (void)
- : input_file_ (ACE_INVALID_HANDLE),
- dump_file_ (ACE_INVALID_HANDLE)
-{
-}
-
-Simple_Tester::~Simple_Tester (void)
-{
-}
-
-
-int
-Simple_Tester::open (void)
-{
- // Initialize stuff
-
- // Open input file (in OVERLAPPED mode)
- this->input_file_ = ACE_OS::open (file,
- GENERIC_READ | FILE_FLAG_OVERLAPPED);
- if (this->input_file_ == ACE_INVALID_HANDLE)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::open"), -1);
-
- // Open dump file (in OVERLAPPED mode)
- this->dump_file_ = ACE_OS::open (dump_file,
- O_CREAT | O_RDWR | O_TRUNC | FILE_FLAG_OVERLAPPED,
- 0644);
- if (this->dump_file_ == ACE_INVALID_HANDLE)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::open"), -1);
-
- // Open ACE_Asynch_Read_File
- if (this->rf_.open (*this, this->input_file_) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_File::open"), -1);
-
- // Open ACE_Asynch_Write_File
- if (this->wf_.open (*this, this->dump_file_) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Write_File::open"), -1);
-
- ACE_DEBUG ((LM_DEBUG,
- "Simple_Tester::open: Files and Asynch Operations opened sucessfully\n"));
-
-
- // Start an asynchronous read file
- if (this->initiate_read_file () == -1)
- return -1;
-
- return 0;
-}
-
-
-int
-Simple_Tester::initiate_read_file (void)
-{
- // Create Message_Block
- ACE_Message_Block *mb = 0;
- ACE_NEW_RETURN (mb, ACE_Message_Block (BUFSIZ + 1), -1);
-
- // Inititiate an asynchronous read from the file
- if (this->rf_.read (*mb,
- mb->size () - 1) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_File::read"), -1);
-
- ACE_DEBUG ((LM_DEBUG,
- "Simple_Tester:initiate_read_file: Asynch Read File issued sucessfully\n"));
-
- return 0;
-}
-
-void
-Simple_Tester::handle_read_file (const ACE_Asynch_Read_File::Result &result)
-{
- ACE_DEBUG ((LM_DEBUG, "handle_read_file called\n"));
-
- result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0';
-
- ACE_DEBUG ((LM_DEBUG, "********************\n"));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ()));
- ACE_DEBUG ((LM_DEBUG, "********************\n"));
- ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ()));
-
- if (result.success ())
- {
- // Read successful: write this to the file.
- if (this->wf_.write (result.message_block (),
- result.bytes_transferred ()) == -1)
- {
- ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_File::write"));
- return;
- }
- }
-}
-
-void
-Simple_Tester::handle_write_file (const ACE_Asynch_Write_File::Result &result)
-{
- ACE_DEBUG ((LM_DEBUG, "handle_write_File called\n"));
-
- // Reset pointers
- result.message_block ().rd_ptr (result.message_block ().rd_ptr () - result.bytes_transferred ());
-
- result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0';
-
- ACE_DEBUG ((LM_DEBUG, "********************\n"));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ()));
- ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ()));
- ACE_DEBUG ((LM_DEBUG, "********************\n"));
- ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ()));
-
- done = 1;
-}
-
-static int
-parse_args (int argc, char *argv[])
-{
- ACE_Get_Opt get_opt (argc, argv, "f:d:");
- int c;
-
- while ((c = get_opt ()) != EOF)
- switch (c)
- {
- case 'f':
- file = get_opt.optarg;
- break;
- case 'd':
- dump_file = get_opt.optarg;
- break;
- default:
- ACE_ERROR ((LM_ERROR, "%p.\n",
- "usage :\n"
- "-d <dumpfile>\n"
- "-f <file>\n"));
- return -1;
- }
-
- return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
- if (parse_args (argc, argv) == -1)
- return -1;
-
- Simple_Tester Simple_Tester;
-
- if (Simple_Tester.open () == -1)
- return -1;
-
- int success = 1;
-
- while (success != -1 && !done)
- {
- // dispatch events
- success = ACE_Proactor::instance ()->handle_events ();
-
- if (success == 0)
- sleep (5);
- }
- return 0;
-}
-
-#endif /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS*/
diff --git a/examples/Reactor/Proactor/test_aiocb.cpp b/examples/Reactor/Proactor/test_aiocb.cpp
index 008121b744a..3bd3ee96b3d 100644
--- a/examples/Reactor/Proactor/test_aiocb.cpp
+++ b/examples/Reactor/Proactor/test_aiocb.cpp
@@ -9,8 +9,14 @@
// test_aiocb.cpp
//
// = DESCRIPTION
-// Checkout $ACE_ROOT/examples/Reactor/Proactor/test_aiocb_ace.cpp,
-// which is the ACE'ified version of this program.
+// This program helps you to test the <aio_*> calls on a
+// platform. Before running this test, make sure the platform can
+// support POSIX <aio_> calls. use $ACE_ROOT/tests for this.
+// This is for testing the AIOCB (AIO Control Blocks) based
+// completion approach which uses <aio_suspend> for completion
+// querying.
+// If this test is successful, ACE_POSIX_AIOCB_PROACTOR
+// can be used on this platform.
//
// = COMPILE and RUN
// % CC -g -o test_aiocb -lrt test_aiocb.cpp
diff --git a/examples/Reactor/Proactor/test_aiocb_ace.cpp b/examples/Reactor/Proactor/test_aiocb_ace.cpp
deleted file mode 100644
index c642a1db2aa..00000000000
--- a/examples/Reactor/Proactor/test_aiocb_ace.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// proactor
-//
-// = FILENAME
-// test_aiocb_ace.cpp
-//
-// = DESCRIPTION
-// This program helps you to test the <aio_*> calls on a
-// platform.
-//
-// Before running this test, make sure the platform can
-// support POSIX <aio_> calls, using
-// ACE_ROOT/tests/Aio_Platform_Test.
-//
-// This program tests the AIOCB (AIO Control Blocks) based
-// completion approach which uses <aio_suspend> for completion
-// querying.
-//
-// If this test is successful, ACE_POSIX_AIOCB_PROACTOR
-// can be used on this platform.
-//
-// = COMPILE and RUN
-// % make
-// % ./test_aiocb_ace
-//
-// = AUTHOR
-// Alexander Babu Arulanthu <alex@cs.wustl.edu>
-//
-// ============================================================================
-
-#include "ace/OS.h"
-#include "ace/ACE.h"
-
-class Test_Aio
-{
-public:
- Test_Aio (void);
- // Default constructor.
-
- int init (void);
- // Initting the output file and the buffer.
-
- int do_aio (void);
- // Doing the testing stuff.
-
- ~Test_Aio (void);
- // Destructor.
-private:
- int out_fd_;
- // Output file descriptor.
-
- struct aiocb *aiocb_write_;
- // For writing to the file.
-
- struct aiocb *aiocb_read_;
- // Reading stuff from the file.
-
- char *buffer_write_;
- // The buffer to be written to the out_fd.
-
- char *buffer_read_;
- // The buffer to be read back from the file.
-};
-
-Test_Aio::Test_Aio (void)
- : aiocb_write_ (0),
- aiocb_read_ (0),
- buffer_write_ (0),
- buffer_read_ (0)
-{
- ACE_NEW (this->aiocb_write_,
- struct aiocb);
- ACE_NEW (this->aiocb_read_,
- struct aiocb);
-}
-
-Test_Aio::~Test_Aio (void)
-{
- delete aiocb_write_;
- delete aiocb_read_;
- delete buffer_write_;
- delete buffer_read_;
-}
-
-// Init the output file and init the buffer.
-int
-Test_Aio::init (void)
-{
- // Open the output file.
- this->out_fd_ = ACE_OS::open ("test_aio.log",
- O_RDWR | O_CREAT | O_TRUNC,
- 0666);
- if (this->out_fd_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error: Opening file\n"),
- -1);
-
- // Init the buffers.
- this->buffer_write_ = ACE::strnew ("Welcome to the world of AIO... AIO Rules !!!");
- ACE_DEBUG ((LM_DEBUG,
- "The buffer : %s\n",
- this->buffer_write_));
-
- // Allocate memory for the read buffer.
- ACE_NEW_RETURN (this->buffer_read_,
- char [strlen (this->buffer_write_)],
- -1);
-
- return 0;
-}
-
-// Set the necessary things for the AIO stuff.
-// Write the buffer asynchly.hmm Disable signals.
-// Go on aio_suspend. Wait for completion.
-// Print out the result.
-int
-Test_Aio::do_aio (void)
-{
- // = Write to the file.
-
- // Setup AIOCB.
- this->aiocb_write_->aio_fildes = this->out_fd_;
- this->aiocb_write_->aio_offset = 0;
- this->aiocb_write_->aio_buf = this->buffer_write_;
- this->aiocb_write_->aio_nbytes = strlen (this->buffer_write_);
- this->aiocb_write_->aio_reqprio = 0;
- this->aiocb_write_->aio_sigevent.sigev_notify = SIGEV_NONE;
- //this->this->aiocb_.aio_sigevent.sigev_signo = SIGRTMAX;
- this->aiocb_write_->aio_sigevent.sigev_value.sival_ptr =
- (void *) this->aiocb_write_;
-
- // Fire off the aio write.
- if (aio_write (this->aiocb_write_) != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "aio_write"),
- -1);
-
- // = Read from that file.
-
- // Setup AIOCB.
- this->aiocb_read_->aio_fildes = this->out_fd_;
- this->aiocb_read_->aio_offset = 0;
- this->aiocb_read_->aio_buf = this->buffer_read_;
- this->aiocb_read_->aio_nbytes = strlen (this->buffer_write_);
- this->aiocb_read_->aio_reqprio = 0;
- this->aiocb_read_->aio_sigevent.sigev_notify = SIGEV_NONE;
- //this->this->aiocb_.aio_sigevent.sigev_signo = SIGRTMAX;
- this->aiocb_read_->aio_sigevent.sigev_value.sival_ptr =
- (void *) this->aiocb_read_;
-
- // Fire off the aio write. If it doesnt get queued, carry on to get
- // the completion for the first one.
- if (aio_read (this->aiocb_read_) < 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "aio_read"),
- -1);
-
- // Wait for the completion on aio_suspend.
- struct aiocb *list_aiocb[2];
- list_aiocb [0] = this->aiocb_write_;
- list_aiocb [1] = this->aiocb_read_;
-
- // Do suspend till all the aiocbs in the list are done.
- int done = 0;
- int return_val = 0;
- while (!done)
- {
- return_val = aio_suspend (list_aiocb,
- 2,
- 0);
- ACE_DEBUG ((LM_DEBUG,
- "Result of <aio_suspend> : %d\n",
- return_val));
-
- // Analyze return and error values.
- if (aio_error (list_aiocb [0]) != EINPROGRESS)
- {
- if (aio_return (list_aiocb [0]) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "aio_return"),
- -1);
- else
- {
- // Successful. Store the pointer somewhere and make the
- // entry NULL in the list.
- this->aiocb_write_ = list_aiocb [0];
- list_aiocb [0] = 0;
- }
- }
- else
- ACE_DEBUG ((LM_DEBUG,
- "aio_error says aio is in progress\n"));
-
- if (aio_error (list_aiocb [1]) != EINPROGRESS)
- {
- if (aio_return (list_aiocb [1]) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "aio_return"),
- -1);
- else
- {
- // Successful. Store the pointer somewhere and make the
- // entry NULL in the list.
- this->aiocb_read_ = list_aiocb [1];
- list_aiocb [1] = 0;
- }
- }
- else
- ACE_DEBUG ((LM_DEBUG,
- "aio_error says aio is in progress\n"));
-
- // Is it done?
- if ((list_aiocb [0] == 0) && (list_aiocb [1] == 0))
- done = 1;
- }
-
- ACE_DEBUG ((LM_DEBUG,
- "Both the AIO operations done.\n"
- "The buffer is : %s\n",
- this->buffer_read_));
-
- return 0;
-}
-
-int
-main (int argc, char **argv)
-{
- Test_Aio test_aio;
-
- if (test_aio.init () != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "AIOCB test failed:\n"
- "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n"),
- -1);
-
- if (test_aio.do_aio () != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "AIOCB test failed:\n"
- "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n"),
- -1);
-
- ACE_DEBUG ((LM_DEBUG,
- "AIOCB test successful:\n"
- "ACE_POSIX_AIOCB_PROACTOR should work in this platform\n"));
-
- return 0;
-}
diff --git a/examples/Reactor/Proactor/test_aiosig.cpp b/examples/Reactor/Proactor/test_aiosig.cpp
index 1746a10a49c..ff4c257af84 100644
--- a/examples/Reactor/Proactor/test_aiosig.cpp
+++ b/examples/Reactor/Proactor/test_aiosig.cpp
@@ -5,11 +5,26 @@
// test_aiosig.cpp
//
// = DESCRITPTION
-// Check out test_aiosig_ace.cpp, the ACE'ified version of this
-// program. This program may not be uptodate.
+// This program helps you to test the <aio_*> calls on a
+// platform.
+// Before running this test, make sure the platform can
+// support POSIX <aio_> calls. use $ACE_ROOT/tests for this.
+// This is for testing the Signal based completion approach which
+// uses <sigtimedwait> for completion querying.
+// If this test is successful, ACE_POSIX_SIG_PROACTOR
+// can be used on this platform.
+// This program is a C-language version of the
+// $ACE_ROOT/examples/Reactor/Proactor/test_aiosig_ace.cpp, with
+// all the ACE calls removed.
+// This test does the following:
+// Issue two <aio_read>s.
+// Assign SIGRTMIN as the notification signal.
+// Mask these signals from delivery.
+// Receive this signal by doing <sigtimedwait>.
+// Wait for two completions (two signals)
//
// = COMPILATION
-// CC -g -o test_aiosig -lrt test_aiosig.cpp
+// CC -g -o test_aiosig -lposix4 test_aiosig.cpp
//
// = RUN
// ./test_aiosig
@@ -45,8 +60,6 @@ int setup_signal_delivery (void);
int issue_aio_calls (void);
int query_aio_completions (void);
int test_aio_calls (void);
-int setup_signal_handler (void);
-int setup_signal_handler (int signal_number);
int
setup_signal_delivery (void)
@@ -65,13 +78,31 @@ setup_signal_delivery (void)
}
// Mask them.
- if (pthread_sigmask (SIG_BLOCK, &completion_signal, 0) == -1)
+ if (sigprocmask (SIG_BLOCK, &completion_signal, 0) == -1)
{
perror ("Error:Couldnt maks the RT completion signals\n");
return -1;
}
- return setup_signal_handler (SIGRTMIN);
+ // Setting up the handler(!) for these signals.
+ struct sigaction reaction;
+ sigemptyset (&reaction.sa_mask); // Nothing else to mask.
+ reaction.sa_flags = SA_SIGINFO; // Realtime flag.
+#if defined (SA_SIGACTION)
+ // Lynx says, it is better to set this bit to be portable.
+ reaction.sa_flags &= SA_SIGACTION;
+#endif /* SA_SIGACTION */
+ reaction.sa_sigaction = 0; // No handler.
+ int sigaction_return = sigaction (SIGRTMIN,
+ &reaction,
+ 0);
+ if (sigaction_return == -1)
+ {
+ perror ("Error:Proactor couldnt do sigaction for the RT SIGNAL");
+ return -1;
+ }
+
+ return 0;
}
int
@@ -251,37 +282,6 @@ test_aio_calls (void)
}
int
-setup_signal_handler (int signal_number)
-{
- // Setting up the handler(!) for these signals.
- struct sigaction reaction;
- sigemptyset (&reaction.sa_mask); // Nothing else to mask.
- reaction.sa_flags = SA_SIGINFO; // Realtime flag.
-#if defined (SA_SIGACTION)
- // Lynx says, it is better to set this bit to be portable.
- reaction.sa_flags &= SA_SIGACTION;
-#endif /* SA_SIGACTION */
- reaction.sa_sigaction = null_handler; // Null handler.
- int sigaction_return = sigaction (SIGRTMIN,
- &reaction,
- 0);
- if (sigaction_return == -1)
- {
- perror ("Error:Proactor couldnt do sigaction for the RT SIGNAL");
- return -1;
- }
-
- return 0;
-}
-
-void
-null_handler (int /* signal_number */,
- siginfo_t * /* info */,
- void * /* context */)
-{
-}
-
-int
main (int, char *[])
{
if (test_aio_calls () == 0)
diff --git a/examples/Reactor/Proactor/test_aiosig_ace.cpp b/examples/Reactor/Proactor/test_aiosig_ace.cpp
index bfb36d78b46..09094727629 100644
--- a/examples/Reactor/Proactor/test_aiosig_ace.cpp
+++ b/examples/Reactor/Proactor/test_aiosig_ace.cpp
@@ -8,17 +8,14 @@
// This program helps you to test the <aio_*> calls on a
// platform.
// Before running this test, make sure the platform can
-// support POSIX <aio_> calls, using ACE_ROOT/tests/Aio_Plaform_Test.cpp
-//
-// This program tests the Signal based completion approach which
+// support POSIX <aio_> calls. use $ACE_ROOT/tests for this.
+// This is for testing the Signal based completion approach which
// uses <sigtimedwait> for completion querying.
// If this test is successful, ACE_POSIX_SIG_PROACTOR
// can be used on this platform.
-//
// This program is a ACE version of the
// $ACE_ROOT/examples/Reactor/Proactor/test_aiosig.cpp, with
// ACE_DEBUGs and Message_Blocks.
-//
// This test does the following:
// Issue two <aio_read>s.
// Assign SIGRTMIN as the notification signal.
@@ -52,51 +49,28 @@ static int setup_signal_delivery (void);
static int issue_aio_calls (void);
static int query_aio_completions (void);
static int test_aio_calls (void);
-static void null_handler (int signal_number, siginfo_t *info, void *context);
-static int setup_signal_handler (int signal_number);
static int
setup_signal_delivery (void)
{
- // = Mask all the signals.
-
- sigset_t full_set;
-
- // Get full set.
- if (sigfillset (&full_set) != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error:(%P | %t):%p\n",
- "sigfillset failed"),
- -1);
-
- // Mask them.
- if (ACE_OS::pthread_sigmask (SIG_SETMASK, &full_set, 0) != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error:(%P | %t):%p\n",
- "pthread_sigmask failed"),
- -1);
-
- // = Make a mask with SIGRTMIN only. We use only that signal to
- // issue <aio_>'s.
-
- if (sigemptyset (&completion_signal) == -1)
+ // Make the sigset_t consisting of the completion signal.
+ if (sigemptyset (&completion_signal) < 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Error:%p:Couldnt init the RT completion signal set\n"),
-1);
if (sigaddset (&completion_signal,
- SIGRTMIN) == -1)
+ SIGRTMIN) < 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Error:%p:Couldnt init the RT completion signal set\n"),
-1);
- // Set up signal handler for this signal.
- return setup_signal_handler (SIGRTMIN);
-}
+ // Mask them.
+ if (sigprocmask (SIG_BLOCK, &completion_signal, 0) < 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error:%p:Couldnt maks the RT completion signals\n"),
+ -1);
-static int
-setup_signal_handler (int signal_number)
-{
// Setting up the handler(!) for these signals.
struct sigaction reaction;
sigemptyset (&reaction.sa_mask); // Nothing else to mask.
@@ -105,7 +79,7 @@ setup_signal_handler (int signal_number)
// Lynx says, it is better to set this bit to be portable.
reaction.sa_flags &= SA_SIGACTION;
#endif /* SA_SIGACTION */
- reaction.sa_sigaction = null_handler; // Null handler.
+ reaction.sa_sigaction = 0; // No handler.
int sigaction_return = sigaction (SIGRTMIN,
&reaction,
0);
@@ -116,7 +90,6 @@ setup_signal_handler (int signal_number)
return 0;
}
-
static int
issue_aio_calls (void)
{
@@ -169,10 +142,10 @@ query_aio_completions (void)
timespec timeout;
timeout.tv_sec = ACE_INFINITE;
timeout.tv_nsec = 0;
-
+
// To get back the signal info.
siginfo_t sig_info;
-
+
// Await the RT completion signal.
int sig_return = sigtimedwait (&completion_signal,
&sig_info,
@@ -185,7 +158,7 @@ query_aio_completions (void)
if (sig_return == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"Error:%p:Error waiting for RT completion signals\n"),
- -1);
+ 0);
// RT completion signals returned.
if (sig_return != SIGRTMIN)
@@ -275,30 +248,18 @@ test_aio_calls (void)
"ACE_OS::open"),
-1);
- if (setup_signal_delivery () == -1)
+ if (setup_signal_delivery () < 0)
return -1;
- if (issue_aio_calls () == -1)
+ if (issue_aio_calls () < 0)
return -1;
- if (query_aio_completions () == -1)
+ if (query_aio_completions () < 0)
return -1;
return 0;
}
-static void
-null_handler (int signal_number,
- siginfo_t */* info */,
- void * /* context */)
-{
- ACE_ERROR ((LM_ERROR,
- "Error:%s:Signal number %d\n"
- "Mask all the RT signals for this thread",
- "ACE_POSIX_SIG_Proactor::null_handler called",
- signal_number));
-}
-
int
main (int, char *[])
{
diff --git a/examples/Reactor/Proactor/test_end_event_loop.cpp b/examples/Reactor/Proactor/test_end_event_loop.cpp
deleted file mode 100644
index 70eff0e5a1c..00000000000
--- a/examples/Reactor/Proactor/test_end_event_loop.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-// $Id$
-// ============================================================================
-//
-// = FILENAME
-// test_end_event_loop.cpp
-//
-// = DESCRITPTION
-// This program tests the event loop mechanism of the
-// Proactor. To end the event loop, threads that are blocked in
-// waiting for completions are woken up and the event loop comes
-// to the end. This is tested in this program.
-//
-// Threads are doing <run_event_loop> with/without time_out
-// values and the main thread calls <end_event_loop>.
-//
-// = COMPILATION
-// make
-//
-// = RUN
-// ./test_end_event_loop
-//
-// = AUTHOR
-// Alexander Babu Arulanthu <alex@cs.wustl.edu>
-//
-// =====================================================================
-
-#include "ace/Proactor.h"
-#include "ace/Synch.h"
-#include "ace/Task.h"
-#include "ace/WIN32_Proactor.h"
-#include "ace/POSIX_Proactor.h"
-
-#if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || \
- (defined (ACE_HAS_AIO_CALLS)) && !defined (ACE_POSIX_AIOCB_PROACTOR))
-// This only works on Win32 platforms and on Unix platforms supporting
-// POSIX aio calls.
-
-class ACE_Export My_Task: public ACE_Task <ACE_NULL_SYNCH>
-{
- // = TITLE
- //
- // Contains thread functions which execute event loops. Each
- // thread waits for a different signal.
- //
-public:
- // Constructor.
- My_Task (void)
- : time_flag_ (0)
- {}
-
-
- virtual ~My_Task (void) {}
- // Destructor.
-
- // If time_flag is zero do the eventloop indefinitely, otherwise do
- // it for finite amount of time (13secs!!!).
- int open (void *timed_event_loop)
- {
- // Set the local variable.
- if (timed_event_loop == 0)
- this->time_flag_ = 0;
- else
- this->time_flag_ = 1;
-
- // Spawn the threads.
- if (this->activate (THR_NEW_LWP, 5) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%N:%l:%p\n",
- "My_Task:open: <activate> failed"),
- -1);
-
- return 0;
- }
-
- // Thread function.
- int svc (void)
- {
- ACE_DEBUG ((LM_DEBUG,
- "(%P|%t):Starting svc routine\n"));
-
- if (this->time_flag_)
- {
- ACE_DEBUG ((LM_DEBUG,
- "(%P|%t):Going to do *timed* <run_event_loop> \n"));
-
- ACE_Time_Value run_time (13);
-
- if (ACE_Proactor::instance ()->run_event_loop (run_time) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t):%p.\n",
- "<Proactor::run_event_loop> failed"),
- -1);
- }
- else
- {
- ACE_DEBUG ((LM_DEBUG,
- "(%P|%t):Going to do *indefinite* <run_event_loop> \n"));
-
- if (ACE_Proactor::instance ()->run_event_loop () == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t):%p.\n",
- "<Proactor::run_event_loop> failed"),
- -1);
- }
- return 0;
- };
-
-private:
- int time_flag_;
- // If zero, indefinite event loop, otherwise timed event loop.
-};
-
-int
-main (int argc, char *argv [])
-{
- ACE_DEBUG ((LM_DEBUG,
- "(%P | %t):Test starts \n"));
-
- // Let us get the singleton proactor created here. This is very
- // important. This will mask the signal used in the Proactor masked
- // for the main thread (and all the threads).
- ACE_Proactor *proactor = ACE_Proactor::instance ();
- ACE_UNUSED_ARG (proactor);
-
- My_Task task1, task2;
-
- // Test the indefinite run event loop.
- if (task1.open (0) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%N:%l:(%P | %t):Failed to <open> the task\n"),
- 1);
-
- // Test the indefinite run event loop. Just pass a non-zero.
- if (task2.open ((void *)&task2) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%N:%l:(%P | %t):Failed to <open> the task\n"),
- 1);
-
- // Give a gap.
- ACE_OS::sleep (3);
-
- // End the event loop.
- if (ACE_Proactor::instance ()->end_event_loop () == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%N:%l:(%P | %t):Failed to <end_event_loop>\n"),
- 1);
-
- ACE_Thread_Manager::instance ()->wait ();
-
- ACE_DEBUG ((LM_DEBUG,
- "(%P | %t):Test ends\n"));
- return 0;
-}
-
-#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Task <ACE_NULL_SYNCH>;
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Task <ACE_NULL_SYNCH>
-#endif /* ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA */
-
-#else /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS && !ACE_POSIX_AIOCB_PROACTOR*/
-
-int
-main (int, char *[])
-{
- ACE_DEBUG ((LM_DEBUG,
- "This example cannot work with AIOCB_Proactor.\n"));
- return 1;
-}
-
-#endif /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS && !ACE_POSIX_AIOCB_PROACTOR*/
-
diff --git a/examples/Reactor/Proactor/test_end_event_loop.dsp b/examples/Reactor/Proactor/test_end_event_loop.dsp
deleted file mode 100644
index cd1ae741ffd..00000000000
--- a/examples/Reactor/Proactor/test_end_event_loop.dsp
+++ /dev/null
@@ -1,90 +0,0 @@
-# Microsoft Developer Studio Project File - Name="test_end_event_loop" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=test_end_event_loop - 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 "test_end_event_loop.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 "test_end_event_loop.mak"\
- CFG="test_end_event_loop - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "test_end_event_loop - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "test_end_event_loop - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "test_end_event_loop - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "test_end_event_loop - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "test_end"
-# PROP BASE Intermediate_Dir "test_end"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "test_end"
-# PROP Intermediate_Dir "test_end"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\ace"
-
-!ENDIF
-
-# Begin Target
-
-# Name "test_end_event_loop - Win32 Release"
-# Name "test_end_event_loop - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\test_end_event_loop.cpp
-# End Source File
-# End Target
-# End Project
diff --git a/examples/Reactor/Proactor/test_proactor.cpp b/examples/Reactor/Proactor/test_proactor.cpp
index 89fe5e67ef2..7d25fd9f3c4 100644
--- a/examples/Reactor/Proactor/test_proactor.cpp
+++ b/examples/Reactor/Proactor/test_proactor.cpp
@@ -33,10 +33,6 @@
ACE_RCSID(Proactor, test_proactor, "$Id$")
-#if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS)))
- // This only works on Win32 platforms and on Unix platforms supporting
- // POSIX aio calls.
-
static char *host = 0;
static u_short port = ACE_DEFAULT_SERVER_PORT;
static char *file = "test_proactor.cpp";
@@ -93,8 +89,8 @@ private:
};
Receiver::Receiver (void)
- : dump_file_ (ACE_INVALID_HANDLE),
- handle_ (ACE_INVALID_HANDLE)
+ : handle_ (ACE_INVALID_HANDLE),
+ dump_file_ (ACE_INVALID_HANDLE)
{
}
@@ -158,7 +154,6 @@ Receiver::open (ACE_HANDLE handle,
initial_read_size,
0,
ACE_INVALID_HANDLE,
- 0,
0);
size_t bytes_transferred = message_block.length ();
@@ -303,9 +298,6 @@ private:
ACE_Asynch_Read_File rf_;
// rf (read file): for writing from the file
- ACE_Asynch_Transmit_File tf_;
- // Transmit file.
-
ACE_HANDLE input_file_;
// File to read from
@@ -400,7 +392,8 @@ Sender::transmit_file (void)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::open"), -1);
// Open ACE_Asynch_Transmit_File
- if (this->tf_.open (*this) == -1)
+ ACE_Asynch_Transmit_File tf;
+ if (tf.open (*this) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Transmit_File::open"), -1);
// Header and trailer data for the file.
@@ -409,11 +402,14 @@ Sender::transmit_file (void)
this->welcome_message_.length (),
this->welcome_message_.duplicate (),
this->welcome_message_.length ());
-
+
+ // Starting position
+ cerr << "Starting position: " << ACE_OS::lseek (file_handle, 0L, SEEK_CUR) << endl;
+
// Send it
- if (this->tf_.transmit_file (file_handle,
+ if (tf.transmit_file (file_handle,
&this->header_and_trailer_) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Transmit_File::transmit_file"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Transmit_File::transmit_file"), -1);
return 0;
}
@@ -436,9 +432,12 @@ Sender::handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result)
ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ()));
ACE_DEBUG ((LM_DEBUG, "********************\n"));
+ // Ending position
+ cerr << "Ending position: " << ACE_OS::lseek (result.file (), 0L, SEEK_CUR) << endl;
+
// Done with file
ACE_OS::close (result.file ());
-
+
this->transmit_file_done_ = 1;
if (this->stream_write_done_)
done = 1;
@@ -582,6 +581,7 @@ parse_args (int argc, char *argv[])
int
main (int argc, char *argv[])
{
+
if (parse_args (argc, argv) == -1)
return -1;
@@ -616,5 +616,3 @@ template class ACE_Asynch_Acceptor<Receiver>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Asynch_Acceptor<Receiver>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
-
-#endif /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS*/
diff --git a/examples/Reactor/Proactor/test_proactor.dsw b/examples/Reactor/Proactor/test_proactor.dsw
index 2d9c24fe896..3983844f0d6 100644
--- a/examples/Reactor/Proactor/test_proactor.dsw
+++ b/examples/Reactor/Proactor/test_proactor.dsw
@@ -3,18 +3,6 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
###############################################################################
-Project: "test_end_event_loop"=.\test_end_event_loop.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
Project: "test_multiple_loops"=.\test_multiple_loops.dsp - Package Owner=<4>
Package=<5>
@@ -27,18 +15,6 @@ Package=<4>
###############################################################################
-Project: "test_post_completion"=.\test_post_completion.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
Project: "test_proactor"=.\test_proactor.dsp - Package Owner=<4>
Package=<5>
diff --git a/examples/Reactor/Proactor/test_timeout.cpp b/examples/Reactor/Proactor/test_timeout.cpp
index 18884b294e0..2835840a555 100644
--- a/examples/Reactor/Proactor/test_timeout.cpp
+++ b/examples/Reactor/Proactor/test_timeout.cpp
@@ -12,12 +12,10 @@
//
// This example application shows how to write event loops that
// handle events for some fixed amount of time. Note that any
-// thread in the Proactor thread pool can call back the handler. On
-// POSIX4 systems, this test works only with POSIX_SIG_Proactor,
-// which can work with multiple threads.
+// thread in the Proactor thread pool can call back the handler
//
// = AUTHOR
-// Irfan Pyarali and Alexander Babu Arulanthu
+// Irfan Pyarali
//
// ============================================================================
@@ -27,37 +25,30 @@
ACE_RCSID(Proactor, test_timeout, "$Id$")
-#if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || \
- (defined (ACE_HAS_AIO_CALLS)) && !defined (ACE_POSIX_AIOCB_PROACTOR))
- // This only works on Win32 platforms and on Unix platforms supporting
- // POSIX aio calls.
-
class Timeout_Handler : public ACE_Handler
-{
// = TITLE
// Generic timeout handler.
+{
public:
Timeout_Handler (void)
: start_time_ (ACE_OS::gettimeofday ())
- {
+ {
}
virtual void handle_time_out (const ACE_Time_Value &tv,
const void *arg)
+ // Print out when timeouts occur.
{
- // Print out when timeouts occur.
ACE_DEBUG ((LM_DEBUG, "(%t) %d timeout occurred for %s @ %d.\n",
++count_,
(char *) arg,
(tv - this->start_time_).sec ()));
-
// Sleep for a while
ACE_OS::sleep (4);
}
private:
ACE_Atomic_Op <ACE_Thread_Mutex, int> count_;
- // Number of the timer event.
ACE_Time_Value start_time_;
// Starting time of the test.
@@ -66,20 +57,18 @@ private:
class Worker : public ACE_Task <ACE_NULL_SYNCH>
{
public:
- int svc (void)
- {
- // Handle events for 13 seconds.
- ACE_Time_Value run_time (13);
-
- ACE_DEBUG ((LM_DEBUG, "(%t):Starting svc routine\n"));
-
- if (ACE_Proactor::run_event_loop(run_time) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "(%t):%p.\n", "Worker::svc"), -1);
-
+ int svc (void)
+ {
+ // Handle events for 13 seconds.
+ ACE_Time_Value run_time (13);
+
+ if (ACE_Proactor::run_event_loop(run_time) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "Worker::svc"), -1);
+ else
ACE_DEBUG ((LM_DEBUG, "(%t) work complete\n"));
-
- return 0;
- }
+
+ return 0;
+ }
};
int
@@ -104,12 +93,11 @@ main (int, char *[])
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1);
Worker worker;
-
+
if (worker.activate (THR_NEW_LWP, 10) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1);
ACE_Thread_Manager::instance ()->wait ();
-
return 0;
}
@@ -118,16 +106,3 @@ template class ACE_Atomic_Op<ACE_Thread_Mutex, int>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
-
-#else /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS && !ACE_POSIX_AIOCB_PROACTOR*/
-
-int
-main (int, char *[])
-{
- ACE_DEBUG ((LM_DEBUG,
- "This example is multithreaded version of test_timeout_st.cpp\n"
- "This doesnt work on this platform !!!\n"));
- return 1;
-}
-
-#endif /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS && !ACE_POSIX_AIOCB_PROACTOR*/
diff --git a/examples/Reactor/Proactor/test_timeout_st.cpp b/examples/Reactor/Proactor/test_timeout_st.cpp
deleted file mode 100644
index cf8372b6c37..00000000000
--- a/examples/Reactor/Proactor/test_timeout_st.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// examples
-//
-// = FILENAME
-// test_timeout_st.cpp
-//
-// = DESCRIPTION
-//
-// This example application shows how to write event loops that
-// handle events for some fixed amount of time. This is the single
-// threaded version of the test_timeout.cpp application.
-//
-// = AUTHOR
-// Irfan Pyarali and Alexander Babu Arulanthu
-//
-// ============================================================================
-
-#include "ace/Proactor.h"
-
-ACE_RCSID(Proactor, test_timeout, "$Id$")
-
-#if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS)))
-// This only works on Win32 platforms and on Unix platforms supporting
-// POSIX aio calls.
-
-class Timeout_Handler : public ACE_Handler
-{
- // = TITLE
- // Generic timeout handler.
-
-public:
- Timeout_Handler (void)
- : count_ (0),
- start_time_ (ACE_OS::gettimeofday ())
- {
- }
-
- virtual void handle_time_out (const ACE_Time_Value &tv,
- const void *arg)
- {
- // Print out when timeouts occur.
- ACE_DEBUG ((LM_DEBUG, "(%t) %d timeout occurred for %s @ %d.\n",
- ++count_,
- (char *) arg,
- (tv - this->start_time_).sec ()));
- }
-
-private:
- int count_;
- // Sequence number for the timeouts.
-
- ACE_Time_Value start_time_;
- // Starting time of the test.
-};
-
-
-int
-main (int, char *[])
-{
- Timeout_Handler handler;
-
- // Register a 2 second timer.
- ACE_Time_Value foo_tv (2);
- if (ACE_Proactor::instance ()->schedule_timer (handler,
- (void *) "Foo",
- ACE_Time_Value::zero,
- foo_tv) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1);
-
- // Register a 3 second timer.
- ACE_Time_Value bar_tv (3);
- if (ACE_Proactor::instance ()->schedule_timer (handler,
- (void *) "Bar",
- ACE_Time_Value::zero,
- bar_tv) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1);
-
- // Handle events for 13 seconds.
- ACE_Time_Value run_time (13);
-
- ACE_DEBUG ((LM_DEBUG, "Starting event loop\n"));
-
- // Run the event loop.
- if (ACE_Proactor::run_event_loop(run_time) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%t):%p.\n", "Worker::svc"),
- 1);
-
- ACE_DEBUG ((LM_DEBUG, "Ending event loop\n"));
-
- return 0;
-}
-
-#endif /* ACE_WIN32 && !ACE_HAS_WINCE || ACE_HAS_AIO_CALLS*/