diff options
Diffstat (limited to 'examples')
92 files changed, 185 insertions, 14739 deletions
diff --git a/examples/Connection/non_blocking/Makefile b/examples/Connection/non_blocking/Makefile index f58eda27196..2e3827415f7 100644 --- a/examples/Connection/non_blocking/Makefile +++ b/examples/Connection/non_blocking/Makefile @@ -948,11 +948,8 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/INET_Addr.h \ $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Connector.i \ CPP-connector.h \ $(ACE_ROOT)/ace/Service_Config.h \ $(ACE_ROOT)/ace/Service_Object.h \ @@ -1093,13 +1090,10 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/Time_Value.h \ $(ACE_ROOT)/ace/TLI_Stream.h \ $(ACE_ROOT)/ace/INET_Addr.h \ $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Acceptor.i \ CPP-acceptor.h \ $(ACE_ROOT)/ace/Acceptor.h \ $(ACE_ROOT)/ace/Service_Config.h \ diff --git a/examples/DLL/test_dll.cpp b/examples/DLL/test_dll.cpp index 45df35c4f87..cbae44b4e0a 100644 --- a/examples/DLL/test_dll.cpp +++ b/examples/DLL/test_dll.cpp @@ -10,8 +10,8 @@ ACE_RCSID(DLL, test_dll, "$Id$") typedef Magazine* (*Magazine_Creator) (void); - -int + +int main (int argc, char *argv[]) { ACE_UNUSED_ARG (argc); @@ -36,13 +36,13 @@ main (int argc, char *argv[]) dll.error ()), -1); { - auto_ptr <Magazine> magazine (mc ()); - + auto_ptr <Magazine> magazine = mc (); + magazine->title (); } dll.close (); - + // The other library is now loaded on demand. retval = dll.open ("./" ACE_DLL_PREFIX "Newsweek" ACE_DLL_SUFFIX); @@ -52,7 +52,7 @@ main (int argc, char *argv[]) "%s", dll.error ()), -1); - + mc = (Magazine_Creator) dll.symbol ("create_magazine"); if (mc == 0) @@ -61,14 +61,14 @@ main (int argc, char *argv[]) dll.error ()), -1); { - auto_ptr <Magazine> magazine (mc ()); + auto_ptr <Magazine> magazine = mc (); magazine->title (); } dll.close (); - - return 0; + + return 0; } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) @@ -76,3 +76,5 @@ template class auto_ptr <Magazine>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate auto_ptr <Magazine> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + + diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp index 7b935dbb983..7a98c2f1bd6 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp @@ -105,9 +105,7 @@ private: char oneway_; // Are we running oneway or twoway? - // Please leave the ; inside the parenthesis to avoid Green Hills - // (and probably other) compiler warning about extra ;. - ACE_MT (ACE_Barrier *barrier_;) + ACE_MT (ACE_Barrier *barrier_); // Barrier used to synchronize the start of all the threads. }; @@ -122,7 +120,7 @@ Options::Options (void) io_source_ (ACE_INVALID_HANDLE), // Defaults to using the generator. iterations_ (10000), oneway_ (1) // Make oneway calls the default. -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +#if defined (ACE_MT_SAFE) , barrier_ (0) #endif /* ACE_MT_SAFE */ { @@ -133,7 +131,7 @@ Options::~Options (void) ACE_MT (delete this->barrier_); delete [] this->message_buf_; } - + // Options Singleton. typedef ACE_Singleton<Options, ACE_SYNCH_RECURSIVE_MUTEX> OPTIONS; @@ -302,7 +300,7 @@ Options::shared_client_test (u_short port, ACE_DEBUG ((LM_DEBUG, "(%P|%t) waiting...\n")); - + // Wait for all other threads to finish initialization. ACE_MT (this->barrier_->wait ()); return buf; @@ -438,9 +436,9 @@ Options::twoway_client_test (void *) double messages_per_sec = iteration * double (ACE_ONE_SECOND_IN_USECS) / real_time; ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("(%t) messages = %d\n(%t) usec-per-message = %f\n(%t) messages-per-second = %0.00f\n"), - iteration, - real_time / double (iteration), + ASYS_TEXT ("(%t) messages = %d\n(%t) usec-per-message = %f\n(%t) messages-per-second = %0.00f\n"), + iteration, + real_time / double (iteration), messages_per_sec < 0 ? 0 : messages_per_sec)); // Close the connection. diff --git a/examples/IPC_SAP/SPIPE_SAP/Makefile b/examples/IPC_SAP/SPIPE_SAP/Makefile index 0f229d640c4..e69b62f51d0 100644 --- a/examples/IPC_SAP/SPIPE_SAP/Makefile +++ b/examples/IPC_SAP/SPIPE_SAP/Makefile @@ -72,8 +72,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/SPIPE.i \ $(ACE_ROOT)/ace/SPIPE_Stream.i \ - $(ACE_ROOT)/ace/SPIPE_Connector.i \ - shared.h + $(ACE_ROOT)/ace/SPIPE_Connector.i .obj/server.o .obj/server.so .shobj/server.o .shobj/server.so: server.cpp \ $(ACE_ROOT)/ace/SPIPE_Addr.h \ $(ACE_ROOT)/ace/Addr.h \ @@ -101,8 +100,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.h \ $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/SPIPE.i \ - $(ACE_ROOT)/ace/SPIPE_Stream.i \ - shared.h + $(ACE_ROOT)/ace/SPIPE_Stream.i .obj/consumer_msg.o .obj/consumer_msg.so .shobj/consumer_msg.o .shobj/consumer_msg.so: consumer_msg.cpp \ $(ACE_ROOT)/ace/SPIPE_Addr.h \ $(ACE_ROOT)/ace/Addr.h \ @@ -130,8 +128,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.h \ $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/SPIPE.i \ - $(ACE_ROOT)/ace/SPIPE_Stream.i \ - shared.h + $(ACE_ROOT)/ace/SPIPE_Stream.i .obj/consumer_read.o .obj/consumer_read.so .shobj/consumer_read.o .shobj/consumer_read.so: consumer_read.cpp \ $(ACE_ROOT)/ace/SPIPE_Addr.h \ $(ACE_ROOT)/ace/Addr.h \ @@ -159,8 +156,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.h \ $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/SPIPE.i \ - $(ACE_ROOT)/ace/SPIPE_Stream.i \ - shared.h + $(ACE_ROOT)/ace/SPIPE_Stream.i .obj/producer_msg.o .obj/producer_msg.so .shobj/producer_msg.o .shobj/producer_msg.so: producer_msg.cpp \ $(ACE_ROOT)/ace/SPIPE_Addr.h \ $(ACE_ROOT)/ace/Addr.h \ @@ -189,8 +185,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/SPIPE.i \ $(ACE_ROOT)/ace/SPIPE_Stream.i \ - $(ACE_ROOT)/ace/SPIPE_Connector.i \ - shared.h + $(ACE_ROOT)/ace/SPIPE_Connector.i .obj/producer_read.o .obj/producer_read.so .shobj/producer_read.o .shobj/producer_read.so: producer_read.cpp \ $(ACE_ROOT)/ace/SPIPE_Addr.h \ $(ACE_ROOT)/ace/Addr.h \ @@ -219,8 +214,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/SPIPE.i \ $(ACE_ROOT)/ace/SPIPE_Stream.i \ - $(ACE_ROOT)/ace/SPIPE_Connector.i \ - shared.h + $(ACE_ROOT)/ace/SPIPE_Connector.i .obj/NPClient.o .obj/NPClient.so .shobj/NPClient.o .shobj/NPClient.so: NPClient.cpp \ $(ACE_ROOT)/ace/SPIPE_Addr.h \ $(ACE_ROOT)/ace/Addr.h \ diff --git a/examples/IPC_SAP/TLI_SAP/CPP-ATM-client.cpp b/examples/IPC_SAP/TLI_SAP/CPP-ATM-client.cpp index a9fe506d555..650060f66d4 100644 --- a/examples/IPC_SAP/TLI_SAP/CPP-ATM-client.cpp +++ b/examples/IPC_SAP/TLI_SAP/CPP-ATM-client.cpp @@ -13,44 +13,18 @@ int main (int argc, char *argv[]) { if (argc < 2) ACE_ERROR_RETURN ((LM_ERROR, - "Usage: %s hostname [-s selector] [QoS in KB/sec]\n", + "Usage: %s hostname [QoS in KB/sec] [timeout]\n", argv[0]), 1); - const char *host = argv[1]; - unsigned char selector = ACE_ATM_Addr::DEFAULT_SELECTOR; - int selector_specified = 0; - int opt; - while ((opt = ACE_OS::getopt (argc, argv, "s:?h")) != EOF) - { - switch(opt) - { - case 's': - selector = ACE_OS::atoi (optarg); - selector_specified = 1; - break; - case '?': - case 'h': - ACE_ERROR_RETURN ((LM_ERROR, - "Usage: %s hostname [-s selector] [QoS in KB/s]\n", - argv[0]), - 1); - } // switch - } // while getopt - - int qos = (argc == 3) ? ACE_OS::atoi (argv[2]) : - (argc == 5) ? ACE_OS::atoi (argv[4]) : 0; - // The timeout really gets ignored since FORE's drivers don't work when - // ioctl or fcntl calls are made on the transport id/file descriptor - int timeout = ACE_DEFAULT_TIMEOUT; + int qos = argc > 2 ? ACE_OS::atoi (argv[2]) : 0; + int timeout = argc > 3 ? ACE_OS::atoi (argv[3]) : ACE_DEFAULT_TIMEOUT; char buf[BUFSIZ]; ACE_TLI_Stream cli_stream; ACE_ATM_Addr remote_addr (host); - if (selector_specified) - remote_addr.set_selector(selector); char hostname[MAXNAMELEN]; ACE_OS::hostname(hostname, MAXNAMELEN); ACE_ATM_Addr local_addr (hostname); diff --git a/examples/IPC_SAP/TLI_SAP/CPP-ATM-server.cpp b/examples/IPC_SAP/TLI_SAP/CPP-ATM-server.cpp index 7bc73e5b702..ce0cf78073a 100644 --- a/examples/IPC_SAP/TLI_SAP/CPP-ATM-server.cpp +++ b/examples/IPC_SAP/TLI_SAP/CPP-ATM-server.cpp @@ -11,31 +11,10 @@ ACE_RCSID(TLI_SAP, CPP_ATM_server, "$Id$") int main (int argc, char *argv[]) { - ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT); - - unsigned char selector = ACE_ATM_Addr::DEFAULT_SELECTOR; - int selector_specified = 0; - int opt; - while ((opt = ACE_OS::getopt (argc, argv, "s:?h")) != EOF) - { - switch(opt) - { - case 's': - selector = ACE_OS::atoi (optarg); - selector_specified = 1; - break; - case '?': - case 'h': - ACE_ERROR_RETURN ((LM_ERROR, - "Usage: %s [-s selector]\n", argv[0]), - 1); - } // switch - } // while getopt + ACE_Time_Value timeout (argc > 1 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_TIMEOUT); // Create a server address. ACE_ATM_Addr addr; - if (selector_specified) - addr.set_selector(selector); // Create a server, reuse the addr. ACE_TLI_Acceptor peer_acceptor; @@ -65,7 +44,7 @@ main (int argc, char *argv[]) for (;;) { char buf[BUFSIZ]; - + // Create a new ACE_TLI_Stream endpoint (note automatic restart // if errno == EINTR). if (peer_acceptor.accept (new_stream, @@ -77,7 +56,7 @@ main (int argc, char *argv[]) "accept")); continue; } - + ACE_DEBUG ((LM_DEBUG, "client %s connected\n", addr.addr_to_string ())); @@ -85,7 +64,7 @@ main (int argc, char *argv[]) // Read data from client (terminate on error). for (int r_bytes; - (r_bytes = new_stream.recv (buf, sizeof buf, 0)) > 0; ) + (r_bytes = new_stream.recv (buf, sizeof buf)) > 0; ) if (ACE_OS::write (ACE_STDOUT, buf, r_bytes) != r_bytes) diff --git a/examples/IPC_SAP/TLI_SAP/Makefile b/examples/IPC_SAP/TLI_SAP/Makefile index 58ec52914a3..5f325491a08 100644 --- a/examples/IPC_SAP/TLI_SAP/Makefile +++ b/examples/IPC_SAP/TLI_SAP/Makefile @@ -71,11 +71,8 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Connector.i + $(ACE_ROOT)/ace/INET_Addr.i .obj/ftp-server.o .obj/ftp-server.so .shobj/ftp-server.o .shobj/ftp-server.so: ftp-server.cpp \ $(ACE_ROOT)/ace/Thread_Manager.h \ $(ACE_ROOT)/ace/Thread.h \ @@ -139,13 +136,10 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/Time_Value.h \ $(ACE_ROOT)/ace/TLI_Stream.h \ $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Acceptor.i + $(ACE_ROOT)/ace/INET_Addr.i .obj/db-client.o .obj/db-client.so .shobj/db-client.o .shobj/db-client.so: db-client.cpp \ $(ACE_ROOT)/ace/TLI_Connector.h \ $(ACE_ROOT)/ace/TLI_Stream.h \ @@ -170,11 +164,8 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Connector.i + $(ACE_ROOT)/ace/INET_Addr.i .obj/db-server.o .obj/db-server.so .shobj/db-server.o .shobj/db-server.so: db-server.cpp \ $(ACE_ROOT)/ace/TLI_Acceptor.h \ $(ACE_ROOT)/ace/TLI.h \ @@ -198,13 +189,10 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/Time_Value.h \ $(ACE_ROOT)/ace/TLI_Stream.h \ $(ACE_ROOT)/ace/INET_Addr.h \ $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Acceptor.i \ $(ACE_ROOT)/ace/Thread_Manager.h \ $(ACE_ROOT)/ace/Thread.h \ $(ACE_ROOT)/ace/Thread.i \ @@ -269,11 +257,8 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Connector.i + $(ACE_ROOT)/ace/INET_Addr.i .obj/CPP-server.o .obj/CPP-server.so .shobj/CPP-server.o .shobj/CPP-server.so: CPP-server.cpp \ $(ACE_ROOT)/ace/TLI_Acceptor.h \ $(ACE_ROOT)/ace/TLI.h \ @@ -297,75 +282,9 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/TLI_Stream.h \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Acceptor.i -.obj/CPP-ATM-client.o .obj/CPP-ATM-client.so .shobj/CPP-ATM-client.o .shobj/CPP-ATM-client.so: CPP-ATM-client.cpp \ - $(ACE_ROOT)/ace/TLI_Connector.h \ - $(ACE_ROOT)/ace/TLI_Stream.h \ - $(ACE_ROOT)/ace/TLI.h \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Connector.i \ - $(ACE_ROOT)/ace/ATM_Addr.h \ - $(ACE_ROOT)/ace/ATM_Addr.i -.obj/CPP-ATM-server.o .obj/CPP-ATM-server.so .shobj/CPP-ATM-server.o .shobj/CPP-ATM-server.so: CPP-ATM-server.cpp \ - $(ACE_ROOT)/ace/TLI_Acceptor.h \ - $(ACE_ROOT)/ace/TLI.h \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/Time_Value.h \ $(ACE_ROOT)/ace/TLI_Stream.h \ $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Acceptor.i \ - $(ACE_ROOT)/ace/ATM_Addr.h \ - $(ACE_ROOT)/ace/ATM_Addr.i + $(ACE_ROOT)/ace/INET_Addr.i # IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Log_Msg/test_log_msg.cpp b/examples/Log_Msg/test_log_msg.cpp index 815afa29cdf..676871b0697 100644 --- a/examples/Log_Msg/test_log_msg.cpp +++ b/examples/Log_Msg/test_log_msg.cpp @@ -4,17 +4,17 @@ // // = LIBRARY // examples/Log_Msg -// +// // = FILENAME // test_log_msg.cpp // // = DESCRIPTION -// This program tests the Log_Msg abstraction and demontrates -// several use cases. +// This program tests the Log_Msg abstraction and demontrates +// several use cases. // // = AUTHOR // Douglas Schmidt -// +// // ============================================================================ @@ -46,58 +46,58 @@ main (int argc, char *argv[]) if (argc > 1) { if (ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::OSTREAM) == -1) - ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); + ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); cause_error (); // Check to see what happened. - if (ACE_LOG_MSG->op_status () == -1 - && ACE_LOG_MSG->errnum () == EWOULDBLOCK) - ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); + if (ACE_LOG_MSG->op_status () == -1 + && ACE_LOG_MSG->errnum () == EWOULDBLOCK) + ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); else - ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); + ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); } else { if (ACE_LOG_MSG->open (argv[0]) == -1) - ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); + ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); cause_error (); // Check to see what happened. - if (ACE_LOG_MSG->op_status () == -1 - && ACE_LOG_MSG->errnum () == EWOULDBLOCK) - ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); + if (ACE_LOG_MSG->op_status () == -1 + && ACE_LOG_MSG->errnum () == EWOULDBLOCK) + ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); else - ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); + ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); // Exercise many different combinations of STDERR and OSTREAM. - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter++, 8, "", "hello", 10000)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter++, 8, "", "hello", 10000)); ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->msg_ostream (&cout); - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter, 8, "", "world", 10000 * counter++)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR); - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter, 8, "", "world", 10000 * counter++)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->msg_ostream (0); ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR); - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter, 8, "", "world", 10000 * counter++)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->msg_ostream (&cerr); - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter, 8, "", "world", 10000 * counter++)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter, 8, "", "world", 10000 * counter++)); static int array[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048}; @@ -112,18 +112,6 @@ main (int argc, char *argv[]) ACE_DEBUG ((LM_INFO, "This LM_INFO message should not print!\n")); ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); - ACE_SET_BITS (priority_mask, LM_INFO); - ACE_LOG_MSG->priority_mask (priority_mask, ACE_Log_Msg::PROCESS); - - ACE_DEBUG ((LM_INFO, "This LM_INFO message should print!\n")); - ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); - - ACE_CLR_BITS (priority_mask, LM_INFO); - ACE_LOG_MSG->priority_mask (priority_mask, ACE_Log_Msg::PROCESS); - - ACE_DEBUG ((LM_INFO, "This LM_INFO message should not print!\n")); - ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); - char *badname = "badname"; char *l_argv[2]; @@ -131,8 +119,8 @@ main (int argc, char *argv[]) l_argv[1] = 0; if (ACE_OS::execv (badname, l_argv) == -1) - ACE_ERROR ((LM_ERROR, "%n: (%x), %p%r%a\n", - 10000, badname, cleanup, 1)); + ACE_ERROR ((LM_ERROR, "%n: (%x), %p%r%a\n", + 10000, badname, cleanup, 1)); } return 0; } 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*/ diff --git a/examples/Service_Configurator/IPC-tests/client/Makefile b/examples/Service_Configurator/IPC-tests/client/Makefile index 8937050e2b7..8fb502a556c 100644 --- a/examples/Service_Configurator/IPC-tests/client/Makefile +++ b/examples/Service_Configurator/IPC-tests/client/Makefile @@ -237,11 +237,8 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/IPC_SAP.i \ $(ACE_ROOT)/ace/Addr.h \ $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/INET_Addr.h \ $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Connector.i \ $(ACE_ROOT)/ace/Get_Opt.h \ $(ACE_ROOT)/ace/Get_Opt.i .obj/remote_dgram_client_test.o .obj/remote_dgram_client_test.so .shobj/remote_dgram_client_test.o .shobj/remote_dgram_client_test.so: remote_dgram_client_test.cpp \ diff --git a/examples/Service_Configurator/IPC-tests/server/Makefile b/examples/Service_Configurator/IPC-tests/server/Makefile index ad9b434c583..d1bf729af2a 100644 --- a/examples/Service_Configurator/IPC-tests/server/Makefile +++ b/examples/Service_Configurator/IPC-tests/server/Makefile @@ -973,10 +973,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/Addr.i \ $(ACE_ROOT)/ace/SPIPE_Addr.i \ $(ACE_ROOT)/ace/SPIPE.i \ - $(ACE_ROOT)/ace/SPIPE_Stream.i \ - Handle_L_SPIPE.i \ - $(ACE_ROOT)/ace/Get_Opt.h \ - $(ACE_ROOT)/ace/Get_Opt.i + $(ACE_ROOT)/ace/SPIPE_Stream.i .obj/Handle_Thr_Stream.o .obj/Handle_Thr_Stream.so .shobj/Handle_Thr_Stream.o .shobj/Handle_Thr_Stream.so: Handle_Thr_Stream.cpp \ $(ACE_ROOT)/ace/Get_Opt.h \ $(ACE_ROOT)/ace/ACE.h \ @@ -1004,11 +1001,8 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/TLI.h \ $(ACE_ROOT)/ace/IPC_SAP.h \ $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/TLI.i \ $(ACE_ROOT)/ace/Time_Value.h \ $(ACE_ROOT)/ace/TLI_Stream.h \ - $(ACE_ROOT)/ace/TLI_Stream.i \ - $(ACE_ROOT)/ace/TLI_Acceptor.i \ Handle_Thr_Stream.h \ $(ACE_ROOT)/ace/Acceptor.h \ $(ACE_ROOT)/ace/Service_Config.h \ @@ -1122,7 +1116,15 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/Dynamic.i \ $(ACE_ROOT)/ace/Acceptor.i \ $(ACE_ROOT)/ace/Acceptor.cpp \ - Handle_Thr_Stream.i Handle_Thr_Stream.cpp + Handle_Thr_Stream.i Handle_Thr_Stream.cpp \ + $(ACE_ROOT)/ace/SOCK_Stream.h \ + $(ACE_ROOT)/ace/SOCK_IO.h \ + $(ACE_ROOT)/ace/SOCK.h \ + $(ACE_ROOT)/ace/SOCK.i \ + $(ACE_ROOT)/ace/SOCK_IO.i \ + $(ACE_ROOT)/ace/SOCK_Stream.i \ + $(ACE_ROOT)/ace/SOCK_Acceptor.h \ + $(ACE_ROOT)/ace/SOCK_Acceptor.i .obj/server_test.o .obj/server_test.so .shobj/server_test.o .shobj/server_test.so: server_test.cpp \ $(ACE_ROOT)/ace/Service_Config.h \ $(ACE_ROOT)/ace/Service_Object.h \ diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphore_Client.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphore_Client.cpp deleted file mode 100644 index b7fe34725e7..00000000000 --- a/examples/System_V_IPC/SV_Semaphores/Semaphore_Client.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "Semaphore_Test.h" -// $Id$ - -#include "ace/SV_Shared_Memory.h" -#include "ace/SV_Semaphore_Simple.h" - -int -main (void) -{ - ACE_SV_Shared_Memory shm_client (SHM_KEY, - SHMSZ, - ACE_SV_Shared_Memory::ACE_OPEN); - ACE_SV_Semaphore_Simple sem (SEM_KEY_1, - ACE_SV_Semaphore_Simple::ACE_OPEN, 0, 2); - - char *s = (char *) shm_client.get_segment_ptr (); - - if (sem.acquire (0) < 0) - ACE_OS::perror ("client sem.acquire"), ACE_OS::exit (1); - - while (*s != '\0') - putchar (*s++); - - putchar ('\n'); - - if (sem.release (1) < 0) - ACE_OS::perror ("client sem.release"), ACE_OS::exit (1); - - return 0; -} - diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp deleted file mode 100644 index f9931705c26..00000000000 --- a/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// $Id$ - - -#include "ace/SV_Shared_Memory.h" -#include "ace/SV_Semaphore_Simple.h" -#include "ace/Signal.h" -#include "Semaphore_Test.h" - -static ACE_SV_Shared_Memory shm_server (SHM_KEY, SHMSZ, ACE_SV_Shared_Memory::ACE_CREATE); -static ACE_SV_Semaphore_Simple sem (SEM_KEY_1, ACE_SV_Semaphore_Simple::ACE_CREATE, 0, 2); - -extern "C" void -cleanup (int) -{ - if (shm_server.remove () < 0 || sem.remove () < 0) - ACE_ERROR ((LM_ERROR, "%p\n%a", "remove", 1)); - ACE_OS::exit (0); -} - -int -main (void) -{ - // Register a signal handler. - ACE_Sig_Action sa ((ACE_SignalHandler) cleanup, SIGINT); - - char *s = (char *) shm_server.get_segment_ptr (); - - for (char c = 'a'; c <= 'z'; c++) - *s++ = c; - - *s = '\0'; - - if (sem.release (0) < 0) - ESD ("server sem.release", done); - - if (sem.acquire (1) < 0) - ESD ("server sem.acquire", done); - -done: - cleanup (); - return 0; -} diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphore_Test.h b/examples/System_V_IPC/SV_Semaphores/Semaphore_Test.h deleted file mode 100644 index 72aab815ff8..00000000000 --- a/examples/System_V_IPC/SV_Semaphores/Semaphore_Test.h +++ /dev/null @@ -1,11 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Log_Msg.h" - -#define SHMSZ 27 -#define SEM_KEY_1 2345 -#define SEM_KEY_2 4321 -#define SHM_KEY 5678 - -#define ESD(MSG,LABEL) do { ACE_ERROR ((LM_ERROR, MSG)); goto LABEL; } while (0) diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphores.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphores.cpp deleted file mode 100644 index b98c664883b..00000000000 --- a/examples/System_V_IPC/SV_Semaphores/Semaphores.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Illustrates the use of the Semaphore_Complex class. Note that it -// $Id$ - -// doesn't matter whether the parent or the child creates the -// semaphore since Semaphore_Complex will correctly serialize the -// intialization of the mutex and synch objects. -#include "ace/Malloc.h" -#include "ace/SV_Semaphore_Complex.h" -#include "Semaphore_Test.h" - -ACE_Malloc<ACE_Shared_Memory_Pool, ACE_SV_Semaphore_Simple> allocator; -ACE_SV_Semaphore_Complex *mutex = 0; -ACE_SV_Semaphore_Complex *synch = 0; - -/* Pointer to memory shared by both the client and server. */ -static char *shm; - -static int -do_parent (void) -{ - char *s = shm; - - mutex = new ACE_SV_Semaphore_Complex (SEM_KEY_1, ACE_SV_Semaphore_Complex::ACE_CREATE, 0); - synch = new ACE_SV_Semaphore_Complex (SEM_KEY_2, ACE_SV_Semaphore_Complex::ACE_CREATE, 0); - - for (char c = 'a'; c <= 'z'; c++) - *s++ = c; - - *s = '\0'; - - if (mutex->release () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p", "server mutex.release"), 1); - - if (synch->acquire () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p", "server synch.acquire"), 1); - return 0; -} - -static int -do_child (void) -{ - mutex = new ACE_SV_Semaphore_Complex (SEM_KEY_1, ACE_SV_Semaphore_Complex::ACE_CREATE, 0); - synch = new ACE_SV_Semaphore_Complex (SEM_KEY_2, ACE_SV_Semaphore_Complex::ACE_CREATE, 0); - - while (mutex->tryacquire () == -1) - if (errno == EAGAIN) - ACE_DEBUG ((LM_DEBUG, "spinning in client!\n")); - else - ACE_ERROR_RETURN ((LM_ERROR, "client mutex.tryacquire"), 1); - - for (char *s = (char *) shm; *s != '\0'; s++) - putchar (*s); - - putchar ('\n'); - - if (synch->release () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "client synch.release"), 1); - return 0; -} - -int -main (void) -{ - shm = (char *) allocator.malloc (27); - - switch (ACE_OS::fork ()) - { - case -1: - ACE_ERROR_RETURN ((LM_ERROR, "fork failed\n"), -1); - /* NOTREACHED */ - case 0: - return do_child (); - default: - { - int result = do_parent (); - - if (wait (0) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "wait"), -1); - - allocator.remove (); - - if (mutex->remove () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mutex.remove"), -1); - else if (synch->remove () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "synch.remove"), -1); - return result; - } - } -} - -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Malloc<ACE_Shared_Memory_Pool, ACE_SV_Semaphore_Simple>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ - diff --git a/examples/Threads/test_auto_event.cpp b/examples/Threads/test_auto_event.cpp deleted file mode 100644 index 4f83d50db71..00000000000 --- a/examples/Threads/test_auto_event.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// $Id$ - -// This test shows the use of an ACE_Auto_Event as a signaling -// mechanism. Two threads are created (one a reader, the other a -// writer). The reader waits till the writer has completed -// calculations. Upon waking up the reader prints the data calculated -// by the writer. The writer thread calculates the value and signals -// the reader when the calculation completes. - -#include "ace/Service_Config.h" -#include "ace/Synch.h" -#include "ace/Singleton.h" -#include "ace/Thread_Manager.h" - -#if defined (ACE_HAS_THREADS) -// Shared event between reader and writer. The ACE_Thread_Mutex is -// necessary to make sure that only one ACE_Auto_Event is created. -// The default constructor for ACE_Auto_Event sets it initially into -// the non-signaled state. - -typedef ACE_Singleton <ACE_Auto_Event, ACE_Thread_Mutex> EVENT; - -// work time for writer -static int work_time; - -// Reader thread. -static void * -reader (void *arg) -{ - // Shared data via a reference. - int& data = *(int *) arg; - - ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); - - // Wait for writer to complete. - - ACE_DEBUG ((LM_DEBUG, "(%t) reader: waiting...... \n")); - - if (EVENT::instance ()->wait () == -1) - { - ACE_ERROR ((LM_ERROR, "thread wait failed")); - ACE_OS::exit (0); - } - - // Read shared data. - ACE_DEBUG ((LM_DEBUG, "(%t) reader: value of data is: %d \n", data)); - - return 0; -} - -// Writer thread. -static void * -writer (void *arg) -{ - int& data = *(int *) arg; - - ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); - - // Calculate (work). - ACE_DEBUG ((LM_DEBUG, "(%t) writer: working for %d secs\n", work_time)); - ACE_OS::sleep (work_time); - - // Write shared data. - data = 42; - - // Wake up reader. - ACE_DEBUG ((LM_DEBUG, "(%t) writer: calculation complete, waking reader\n")); - - if (EVENT::instance ()->signal () == -1) - { - ACE_ERROR ((LM_ERROR, "thread wait failed")); - ACE_OS::exit (0); - } - - return 0; -} - -int -main (int argc, char **argv) -{ - // Shared data: set by writer, read by reader. - int data; - - // Work time for writer. - work_time = argc == 2 ? atoi (argv[1]) : 5; - - // threads manager - ACE_Thread_Manager& tm = *ACE_Service_Config::thr_mgr (); - - // Create reader thread. - if (tm.spawn (reader, (void *) &data) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "thread create for reader failed"), -1); - - // Create writer thread. - if (tm.spawn (writer, (void *) &data) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "thread create for writer failed"), -1); - - // Wait for both. - if (tm.wait () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "thread wait failed"), -1); - else - ACE_DEBUG ((LM_ERROR, "graceful exit\n")); - - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_barrier1.cpp b/examples/Threads/test_barrier1.cpp deleted file mode 100644 index 6b213819ca0..00000000000 --- a/examples/Threads/test_barrier1.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// This test program illustrates how the ACE barrier synchronization -// $Id$ - -// mechanisms work. - - -#include "ace/Synch.h" -#include "ace/Thread_Manager.h" -#include "ace/Service_Config.h" - -#if defined (ACE_HAS_THREADS) - -struct Tester_Args - // = TITLE - // These arguments are passed into each test thread. -{ - Tester_Args (ACE_Barrier &tb, int i) - : tester_barrier_ (tb), - n_iterations_ (i) {} - - ACE_Barrier &tester_barrier_; - // Reference to the tester barrier. This controls each miteration of - // the tester function running in every thread. - - int n_iterations_; - // Number of iterations to run. -}; - -// Iterate <n_iterations> time printing off a message and "waiting" -// for all other threads to complete this iteration. - -static void * -tester (Tester_Args *args) -{ - // Keeps track of thread exit. - ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); - - for (int iterations = 1; - iterations <= args->n_iterations_; - iterations++) - { - ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d\n", iterations)); - - // Block until all other threads have waited, then continue. - args->tester_barrier_.wait (); - } - - return 0; -} - -// Default number of threads to spawn. -static const int DEFAULT_ITERATIONS = 5; - -int -main (int argc, char *argv[]) -{ - ACE_Service_Config daemon (argv[0]); - - int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; - int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; - - ACE_Barrier tester_barrier (n_threads); - - Tester_Args args (tester_barrier, n_iterations); - - if (ACE_Service_Config::thr_mgr ()->spawn_n - (n_threads, ACE_THR_FUNC (tester), - (void *) &args, THR_NEW_LWP | THR_DETACHED) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); - - // Wait for all the threads to reach their exit point. - ACE_Service_Config::thr_mgr ()->wait (); - - ACE_DEBUG ((LM_DEBUG, "(%t) done\n")); - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_barrier2.cpp b/examples/Threads/test_barrier2.cpp deleted file mode 100644 index 30190ace443..00000000000 --- a/examples/Threads/test_barrier2.cpp +++ /dev/null @@ -1,269 +0,0 @@ -// $Id$ - -// generic_worker_task.cpp -// -// This test program illustrates how the ACE task workers/barrier -// synchronization mechanisms work in conjunction with the ACE_Task -// and the ACE_Thread_Manager. The manual flag not set simulates -// user input, if set input comes from stdin until RETURN only is -// entered which stops all workers via a message block of length -// 0. This is an alernative shutdown of workers compared to queue -// deactivate. The delay_put flag simulates a delay between the -// shutdown puts. All should work with this flag disabled! The -// BARRIER_TYPE is supposed to enable/disable barrier sync on each svc -// a worker has done. - -#include <iostream.h> -#include "ace/Task.h" -#include "ace/Service_Config.h" - -#if defined (ACE_HAS_THREADS) - -#define BARRIER_TYPE ACE_Null_Barrier -//#define BARRIER_TYPE ACE_Barrier -//#ifdef delay_put -//#define manual - -template <class BARRIER> -class Worker_Task : public ACE_Task<ACE_MT_SYNCH> -{ -public: - - Worker_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int inp_serialize = 1); - - virtual int Producer (void); - // produce input for workers - - virtual int input (ACE_Message_Block *mb); - // Fill one message block via a certain input strategy. - - virtual int output (ACE_Message_Block *mb); - // Forward one message block via a certain output strategy to the - // next task if any. - - virtual int service (ACE_Message_Block *mb, int iter); - // Perform one message block dependant service. - -private: - virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv=0); - - virtual int svc (void); - // Iterate <n_iterations> time printing off a message and "waiting" - // for all other threads to complete this iteration. - - // = Not needed for this test. - virtual int open (void *) { return 0; } - virtual int close (u_long) {ACE_DEBUG ((LM_DEBUG,"(%t) in close of worker\n")); return 0; } - - int nt_; - // Number of worker threads to run. - int inp_serialize_; - - BARRIER barrier_; -}; - -template <class BARRIER> -Worker_Task<BARRIER>::Worker_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int inp_serialize) - : ACE_Task<ACE_MT_SYNCH> (thr_mgr), - barrier_ (n_threads) -{ - nt_ = n_threads; - // Create worker threads. - inp_serialize_ = inp_serialize; - - // Use the task's message queue for serialization (default) or run - // service in the context of the caller thread. - - if (nt_ > 0 && inp_serialize == 1) - if (this->activate (THR_NEW_LWP, n_threads) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); -} - -// Simply enqueue the Message_Block into the end of the queue. - -template <class BARRIER> int -Worker_Task<BARRIER>::put (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - int result; - if (this->inp_serialize_) - result = this->putq (mb, tv); - else - { - static int iter = 0; - result = this->service (mb, iter++); - - if (this->output (mb) < 0) - ACE_DEBUG ((LM_DEBUG, "(%t) output not connected!\n")); - - delete mb; - } - return result; -} - -template <class BARRIER> int -Worker_Task<BARRIER>::service (ACE_Message_Block *mb, int iter) -{ - int length = mb->length (); - - if (length > 0) - { - ACE_DEBUG ((LM_DEBUG,"(%t) in iteration %d len=%d text got:\n",iter,length)); - ACE_OS::write (ACE_STDOUT, mb->rd_ptr (), length); - ACE_DEBUG ((LM_DEBUG,"\n")); - } - return 0; -} - -// Iterate <n_iterations> time printing off a message and "waiting" -// for all other threads to complete this iteration. - -template <class BARRIER> int -Worker_Task<BARRIER>::svc (void) -{ - // Note that the ACE_Task::svc_run () method automatically adds us - // to the Thread_Manager when the thread begins. - - // Keep looping, reading a message out of the queue, until we get a - // message with a length == 0, which signals us to quit. - - for (int iter = 1; ;iter++) - { - ACE_Message_Block *mb = 0; - - int result = this->getq (mb); - - if (result == -1) - { - ACE_ERROR ((LM_ERROR, - "(%t) in iteration %d\n", "error waiting for message in iteration", iter)); - break; - } - - int length = mb->length (); - this->service (mb,iter); - - if (length == 0) - { - ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d got quit, exit!\n", iter)); - delete mb; - break; - } - - this->barrier_.wait (); - this->output (mb); - - delete mb; - } - - // Note that the ACE_Task::svc_run () method automatically removes - // us from the Thread_Manager when the thread exits. - - return 0; -} - -template <class BARRIER> int -Worker_Task<BARRIER>::Producer (void) -{ - // Keep reading stdin, until we reach EOF. - - for (;;) - { - // Allocate a new message. - ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); - - if (this->input (mb) == -1) - return -1; - } - - return 0; -} - -template <class BARRIER>int -Worker_Task<BARRIER>::output (ACE_Message_Block *mb) -{ - return this->put_next (mb); -} - -template <class BARRIER>int -Worker_Task<BARRIER>::input (ACE_Message_Block *mb) -{ - ACE_Message_Block *mb1; - -#ifndef manual - static int l= 0; - char str[]="kalle"; - strcpy (mb->rd_ptr (),str); - int n=strlen (str); - if (l==1000) - n=1; - l++; - if (l==0 || (l%100 == 0)) ACE_OS::sleep (5); - if (n <= 1) -#else - ACE_DEBUG ((LM_DEBUG,"(%t) press chars and enter to put a new message into task queue ...\n")); - if ((n = read (0, mb->rd_ptr (), mb->size ())) <= 1) -#endif // manual - { - // Send a shutdown message to the waiting threads and exit. - // cout << "\nvor loop, dump of task msg queue:\n" << endl; - // this->msg_queue ()->dump (); - for (int i=0;i<nt_;i++) - { - ACE_DEBUG ((LM_DEBUG,"(%t) eof, sending block for thread=%d\n",i+1)); - mb1 = new ACE_Message_Block (2); - mb1->length (0); - if (this->put (mb1) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put")); -#ifdef delay_put - ACE_OS::sleep (1); // this sleep helps to shutdown correctly -> was an error! -#endif /* delay_put */ - } - // cout << "\nnach loop, dump of task msg queue:\n" << endl; - // this->msg_queue ()->dump (); - return (-1); - } - else - { - // Send a normal message to the waiting threads and continue producing. - mb->wr_ptr (n); - if (this->put (mb) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "put")); - } - return 0; -} - -int -main (int argc, char *argv[]) -{ - int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; - - ACE_DEBUG ((LM_DEBUG,"(%t) worker threads running=%d\n",n_threads)); - - - Worker_Task<BARRIER_TYPE> *worker_task = - new Worker_Task<BARRIER_TYPE> (ACE_Service_Config::thr_mgr (), - /*n_threads*/ 0,0); - - worker_task->Producer (); - - // Wait for all the threads to reach their exit point. - ACE_DEBUG ((LM_DEBUG,"(%t) waiting with thread manager ...\n")); - ACE_Service_Config::thr_mgr ()->wait (); - ACE_DEBUG ((LM_DEBUG,"(%t) delete worker task ...\n")); - - delete worker_task; - ACE_DEBUG ((LM_DEBUG,"(%t) done correct!\n")); - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_cancel.cpp b/examples/Threads/test_cancel.cpp deleted file mode 100644 index a9d12bea579..00000000000 --- a/examples/Threads/test_cancel.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Test out the cooperative thread cancellation mechanisms provided by -// $Id$ - -// the ACE_Thread_Manager. - -#include "ace/Service_Config.h" -#include "ace/Thread_Manager.h" - -#if defined (ACE_HAS_THREADS) - -static void * -worker (int iterations) -{ - for (int i = 0; i < iterations; i++) - { - if ((i % 10) == 0 - && (ACE_Service_Config::thr_mgr ()->testcancel (ACE_Thread::self ()) != 0)) - { - ACE_DEBUG ((LM_DEBUG, "(%t) has been cancelled before iteration!\n", i)); - break; - } - } - - return 0; -} - -static const int DEFAULT_THREADS = ACE_DEFAULT_THREADS; -static const int DEFAULT_ITERATIONS = 100000; - -int -main (int argc, char *argv[]) -{ - ACE_Service_Config daemon; - - daemon.open (argv[0]); - - int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_THREADS; - int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; - - ACE_Thread_Manager *thr_mgr = ACE_Service_Config::thr_mgr (); - - int grp_id = thr_mgr->spawn_n (n_threads, ACE_THR_FUNC (worker), - (void *) n_iterations, - THR_NEW_LWP | THR_DETACHED); - - // Wait for 2 seconds and then suspend every thread in the group. - ACE_OS::sleep (2); - thr_mgr->suspend_grp (grp_id); - - // Wait for 2 more seconds and then resume every thread in the - // group. - ACE_OS::sleep (ACE_Time_Value (2)); - thr_mgr->resume_grp (grp_id); - - // Wait for 2 more seconds and then send a SIGINT to every thread in - // the group. - ACE_OS::sleep (ACE_Time_Value (2)); - thr_mgr->kill_grp (grp_id, SIGINT); - - // Wait for 2 more seconds and then exit (which should kill all the - // threads)! - ACE_OS::sleep (ACE_Time_Value (2)); - - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_future1.cpp b/examples/Threads/test_future1.cpp deleted file mode 100644 index 79cf0a42b36..00000000000 --- a/examples/Threads/test_future1.cpp +++ /dev/null @@ -1,420 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// tests -// -// = FILENAME -// Test_Future.cpp -// -// = DESCRIPTION -// This example tests the ACE Future. -// -// = AUTHOR -// Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt -// <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#include <math.h> -#include "ace/Task.h" - -#include "ace/Synch.h" -#include "ace/Message_Queue.h" -#include "ace/Future.h" -#include "ace/Method_Object.h" -#include "ace/Activation_Queue.h" -#include "ace/Auto_Ptr.h" - -#if defined (ACE_HAS_THREADS) - -typedef ACE_Atomic_Op<ACE_Thread_Mutex, u_long> ATOMIC_INT; - -// a counter for the tasks.. -static ATOMIC_INT task_count (0); - -// a counter for the futures.. -static ATOMIC_INT future_count (0); -static ATOMIC_INT future_no (0); - -// a counter for the capsules.. -static ATOMIC_INT capsule_count (0); -static ATOMIC_INT capsule_no (0); - -// a counter for the method objects... -static ATOMIC_INT methodobject_count (0); -static ATOMIC_INT methodobject_no (0); - -class Scheduler : public ACE_Task<ACE_MT_SYNCH> - // = TITLE - // Active Object Scheduler. -{ - friend class Method_ObjectWork; -public: - Scheduler (const char *, Scheduler * = 0); - ~Scheduler (void); - - virtual int open (void *args = 0); - virtual int close (u_long flags = 0); - virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv = 0); - virtual int svc (void); - - ACE_Future<float> work (float param, int count); - ACE_Future<const char*> name (void); - void end (void); - - float work_i (float, int); - const char *name_i (void); - -private: - char *name_; - ACE_Activation_Queue activation_queue_; - Scheduler *scheduler_; - -}; - -class Method_Object_work : public ACE_Method_Object - // = TITLE - // Reification of the <work> method. -{ -public: - Method_Object_work (Scheduler *, float, int, ACE_Future<float> &); - ~Method_Object_work (void); - virtual int call (void); - -private: - Scheduler *scheduler_; - float param_; - int count_; - ACE_Future<float> future_result_; -}; - -Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, - float new_param, - int new_count, - ACE_Future<float> &new_result) - : scheduler_ (new_Scheduler), - param_ (new_param), - count_ (new_count), - future_result_ (new_result) -{ - ACE_DEBUG ((LM_DEBUG, - "(%t) Method_Object_work created\n")); -} - -Method_Object_work::~Method_Object_work (void) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) Method_Object_work will be deleted.\n")); -} - - -int -Method_Object_work::call (void) -{ - return this->future_result_.set (this->scheduler_->work_i (this->param_, this->count_)); -} - -class Method_Object_name : public ACE_Method_Object - // = TITLE - // Reification of the <name> method. -{ -public: - Method_Object_name (Scheduler *, ACE_Future<const char*> &); - ~Method_Object_name (void); - virtual int call (void); - -private: - Scheduler *scheduler_; - ACE_Future<const char*> future_result_; -}; - -Method_Object_name::Method_Object_name (Scheduler *new_scheduler, - ACE_Future<const char*> &new_result) - : scheduler_ (new_scheduler), - future_result_ (new_result) -{ - ACE_DEBUG ((LM_DEBUG, - "(%t) Method_Object_name created\n")); -}; - -Method_Object_name::~Method_Object_name (void) -{ - ACE_DEBUG ((LM_DEBUG, - "(%t) Method_Object_name will be deleted.\n")); -} - -int -Method_Object_name::call (void) -{ - return future_result_.set (scheduler_->name_i ()); -} - -class Method_Object_end : public ACE_Method_Object - // = TITLE - // Reification of the <end> method. -{ -public: - Method_Object_end (Scheduler *new_Scheduler): scheduler_ (new_Scheduler) {} - ~Method_Object_end (void) {} - virtual int call (void) { this->scheduler_->close (); return -1; } - -private: - Scheduler *scheduler_; -}; - -// constructor -Scheduler::Scheduler (const char *newname, Scheduler *new_Scheduler) -{ - ACE_NEW (this->name_, char[ACE_OS::strlen (newname) + 1]); - ACE_OS::strcpy ((char *) this->name_, newname); - this->scheduler_ = new_Scheduler; - ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s created\n", this->name_)); -} - -// Destructor -Scheduler::~Scheduler (void) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s will be destroyed\n", this->name_)); -} - -// open -int -Scheduler::open (void *) -{ - task_count++; - ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s open\n", this->name_)); - return this->activate (THR_BOUND); -} - -// close -int -Scheduler::close (u_long) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s close\n", this->name_)); - task_count--; - return 0; -} - -// put... ?? -int -Scheduler::put (ACE_Message_Block *, ACE_Time_Value *) -{ - return 0; -} - -// service.. -int -Scheduler::svc (void) -{ - for (;;) - { - // Dequeue the next method object (we use an auto pointer in - // case an exception is thrown in the <call>). - ACE_Auto_Ptr<ACE_Method_Object> mo (this->activation_queue_.dequeue ()); - - ACE_DEBUG ((LM_DEBUG, "(%t) calling method object\n")); - // Call it. - if (mo->call () == -1) - break; - // Destructor automatically deletes it. - } - - /* NOTREACHED */ - return 0; -} - -void -Scheduler::end (void) -{ - this->activation_queue_.enqueue (new Method_Object_end (this)); -} - - -// Here's where the Work takes place. -float -Scheduler::work_i (float param, - int count) -{ - float x = 0, y = 0; - - // @@ We should probably do something fun here, like compute the - // Fibonacci sequence or something. - - for (int j = 0; j < count; j++) - { - x = x + param; - y = y + ::sin (x); - } - - return y; -} - -const char * -Scheduler::name_i (void) -{ - char *the_name; - - the_name = new char[ACE_OS::strlen (this->name_) + 1]; - ACE_OS::strcpy (the_name, this->name_); - - return the_name; -} - -ACE_Future<const char *> -Scheduler::name (void) -{ - if (this->scheduler_) - // Delegate to the Scheduler. - return this->scheduler_->name (); - else - { - ACE_Future<const char*> new_future; - - // @@ What happens if new fails here? - this->activation_queue_.enqueue - (new Method_Object_name (this, new_future)); - - return new_future; - } -} - -ACE_Future<float> -Scheduler::work (float newparam, int newcount) -{ - if (this->scheduler_) { - return this->scheduler_->work (newparam, newcount); - } - else { - ACE_Future<float> new_future; - - this->activation_queue_.enqueue - (new Method_Object_work (this, newparam, newcount, new_future)); - return new_future; - } -} - -// @@ These values should be set by the command line options! - -// Total number of iterations to <work> -static int n_iterations = 50000; - -// Total number of loops. -static int n_loops = 100; - -int -main (int, char *[]) -{ - Scheduler *andres, *peter, *helmut, *matias; - - // Create active objects.. - // @@ Should "open" be subsumed within the constructor of - // Scheduler()? - andres = new Scheduler ("andres"); - andres->open (); - peter = new Scheduler ("peter"); - peter->open (); - helmut = new Scheduler ("helmut"); - helmut->open (); - - // Matias passes all asynchronous method calls on to Andres... - matias = new Scheduler ("matias", andres); - matias->open (); - - for (int i = 0; i < n_loops; i++) - { - { - ACE_Future<float> fresulta, fresultb, fresultc, fresultd, fresulte; - ACE_Future<const char*> fname; - - ACE_DEBUG ((LM_DEBUG, "(%t) going to do a non-blocking call\n")); - - fresulta = andres->work (0.01, 100 + (n_iterations * (i % 2))); - fresultb = peter->work (0.01, 100 + (n_iterations * (i % 2))); - fresultc = helmut->work (0.01, 100 + (n_iterations * (i % 2))); - fresultd = matias->work (0.02, 100 + (n_iterations * (i % 2))); - fname = andres->name (); - - // see if the result is available... - if (fresulta.ready ()) - ACE_DEBUG ((LM_DEBUG, "(%t) wow.. work is ready.....\n")); - - ACE_DEBUG ((LM_DEBUG, "(%t) non-blocking call done... now blocking...\n")); - - // Save the result of fresulta. - - fresulte = fresulta; - - if (i % 3 == 0) - { - // Every 3rd time... disconnect the futures... - // but "fresulte" should still contain the result... - fresulta.cancel (10.0); - fresultb.cancel (20.0); - fresultc.cancel (30.0); - fresultd.cancel (40.0); - } - - float resulta = 0, resultb = 0, resultc = 0, resultd = 0, resulte = 0; - - fresulta.get (resulta); - fresultb.get (resultb); - fresultc.get (resultc); - fresultd.get (resultd); - fresulte.get (resulte); - - ACE_DEBUG ((LM_DEBUG, "(%t) result a %f\n", resulte)); - ACE_DEBUG ((LM_DEBUG, "(%t) result b %f\n", resulta)); - ACE_DEBUG ((LM_DEBUG, "(%t) result c %f\n", resultb)); - ACE_DEBUG ((LM_DEBUG, "(%t) result d %f\n", resultc)); - ACE_DEBUG ((LM_DEBUG, "(%t) result e %f\n", resultd)); - - const char *name; - - fname.get (name); - - ACE_DEBUG ((LM_DEBUG, "(%t) name %s\n", name)); - - } - - ACE_DEBUG ((LM_DEBUG, - "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", - (u_long) task_count, - (u_long) future_count, - (u_long) capsule_count, - (u_long) methodobject_count)); - } - - // Close things down. - andres->end (); - peter->end (); - helmut->end (); - matias->end (); - - ACE_OS::sleep (2); - - ACE_DEBUG ((LM_DEBUG, - "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", - (u_long) task_count, - (u_long) future_count, - (u_long) capsule_count, - (u_long) methodobject_count)); - - ACE_DEBUG ((LM_DEBUG,"(%t) th' that's all folks!\n")); - - ACE_OS::sleep (5); - return 0; -} - -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ - -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_future2.cpp b/examples/Threads/test_future2.cpp deleted file mode 100644 index 19431072202..00000000000 --- a/examples/Threads/test_future2.cpp +++ /dev/null @@ -1,524 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// tests -// -// = FILENAME -// Test_Future.cpp -// -// = DESCRIPTION -// This example tests the ACE Future. -// -// = AUTHOR -// Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt -// <schmidt@cs.wustl.edu> -// -// Modification History -// Aug. 96; A.Kruse; dev. -// Aug. 96; D.Schmidt; complete workover -// 08/27/96; A.Kruse; - the friends of Scheduler are "Method_Object_name" -// and "Method_Object_work". -// - make the methods "work_i" and "name_i" private -// 09/2/96; D.Schmidt; Integrate with new ACE_Future API and rearrange -// the tests so they are more modular. -// ============================================================================ - -#include <math.h> -#include "ace/Task.h" - -#include "ace/Synch.h" -#include "ace/Message_Queue.h" -#include "ace/Future.h" -#include "ace/Method_Object.h" -#include "ace/Activation_Queue.h" -#include "ace/Auto_Ptr.h" - -#if defined (ACE_HAS_THREADS) - -typedef ACE_Atomic_Op<ACE_Thread_Mutex, u_long> ATOMIC_INT; - -// a counter for the tasks.. -static ATOMIC_INT scheduler_open_count (0); - -// forward declarations -class Method_Object_work; -class Method_Object_name; - -class Scheduler : public ACE_Task<ACE_MT_SYNCH> - // = TITLE - // Active Object Scheduler. -{ - // Every method object has to be able to access the private methods. - - friend class Method_Object_work; - friend class Method_Object_name; - friend class Method_Object_end; -public: - - Scheduler (const char *, Scheduler * = 0); - ~Scheduler (void); - - virtual int open (void *args = 0); - // The method that is used to start the active object. - - // = Here are the methods exported by the class. They return an - // <ACE_Future>. - ACE_Future<float> work (float param, int count); - ACE_Future<char*> name (void); - void end (void); - -private: - virtual int close (u_long flags = 0); - // Should not be accessible from outside... (use end () instead). - - virtual int put (ACE_Message_Block *, ACE_Time_Value * = 0) - { return 0; }; - // Doesn't have any use for this example. - - virtual int svc (void); - // Here the actual servicing of all requests is happening.. - - // = Implementation methods. - float work_i (float, int); - char *name_i (void); - - char *name_; - ACE_Activation_Queue activation_queue_; - Scheduler *scheduler_; -}; - -class Method_Object_work : public ACE_Method_Object - // = TITLE - // Reification of the <work> method. -{ -public: - Method_Object_work (Scheduler *, float, int, ACE_Future<float> &); - ~Method_Object_work (void); - virtual int call (void); - -private: - Scheduler *scheduler_; - float param_; - int count_; - ACE_Future<float> future_result_; -}; - -Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, - float new_param, - int new_count, - ACE_Future<float> &new_result) - : scheduler_ (new_Scheduler), - param_ (new_param), - count_ (new_count), - future_result_ (new_result) -{ -} - -Method_Object_work::~Method_Object_work (void) -{ -} - -int -Method_Object_work::call (void) -{ - return this->future_result_.set (this->scheduler_->work_i (this->param_, this->count_)); -} - -class Method_Object_name : public ACE_Method_Object - // = TITLE - // Reification of the <name> method. -{ -public: - Method_Object_name (Scheduler *, ACE_Future<char*> &); - ~Method_Object_name (void); - virtual int call (void); - -private: - Scheduler *scheduler_; - ACE_Future<char*> future_result_; -}; - - -Method_Object_name::Method_Object_name (Scheduler *new_scheduler, - ACE_Future<char*> &new_result) - : scheduler_ (new_scheduler), - future_result_ (new_result) -{ - ACE_DEBUG ((LM_DEBUG, - " (%t) Method_Object_name created\n")); -}; - -Method_Object_name::~Method_Object_name (void) -{ - ACE_DEBUG ((LM_DEBUG, - " (%t) Method_Object_name will be deleted.\n")); -} - -int -Method_Object_name::call (void) -{ - return future_result_.set (scheduler_->name_i ()); -} - -class Method_Object_end : public ACE_Method_Object - // = TITLE - // Reification of the <end> method. -{ -public: - Method_Object_end (Scheduler *new_Scheduler): scheduler_ (new_Scheduler) {} - ~Method_Object_end (void) {} - virtual int call (void) { this->scheduler_->close (); return -1; } - -private: - Scheduler *scheduler_; -}; - -// constructor -Scheduler::Scheduler (const char *newname, Scheduler *new_Scheduler) -{ - ACE_NEW (this->name_, char[ACE_OS::strlen (newname) + 1]); - ACE_OS::strcpy ((char *) this->name_, newname); - this->scheduler_ = new_Scheduler; - ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s created\n", this->name_)); -} - -// Destructor -Scheduler::~Scheduler (void) -{ - ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s will be destroyed\n", this->name_)); -} - -int -Scheduler::open (void *) -{ - scheduler_open_count++; - ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s open\n", this->name_)); - return this->activate (THR_BOUND); -} - -int -Scheduler::close (u_long) -{ - ACE_DEBUG ((LM_DEBUG, " (%t) Scheduler %s close\n", this->name_)); - scheduler_open_count--; - return 0; -} - -int -Scheduler::svc (void) -{ - // Main event loop for this active object. - for (;;) - { - // Dequeue the next method object (we use an auto pointer in - // case an exception is thrown in the <call>). - ACE_Auto_Ptr<ACE_Method_Object> mo (this->activation_queue_.dequeue ()); - - ACE_DEBUG ((LM_DEBUG, " (%t) calling method object\n")); - // Call it. - if (mo->call () == -1) - break; - // Smart pointer destructor automatically deletes mo. - } - - /* NOTREACHED */ - return 0; -} - -void -Scheduler::end (void) -{ - this->activation_queue_.enqueue (new Method_Object_end (this)); -} - -// Here's where the Work takes place. -float -Scheduler::work_i (float param, - int count) -{ - float x = 0, y = 0; - - for (int j = 0; j < count; j++) - { - x = x + param; - y = y + ::sin (x); - } - - return y; -} - -char * -Scheduler::name_i (void) -{ - char *the_name; - - the_name = new char[ACE_OS::strlen (this->name_) + 1]; - ACE_OS::strcpy (the_name, this->name_); - - return the_name; -} - -ACE_Future<char *> -Scheduler::name (void) -{ - if (this->scheduler_) - // Delegate to the other scheduler - return this->scheduler_->name (); - else - { - ACE_Future<char*> new_future; - - if (this->thr_count () == 0) - { - // This scheduler is inactive... so we execute the user - // request right away... - - ACE_Auto_Ptr<ACE_Method_Object> mo (new Method_Object_name (this, new_future)); - - mo->call (); - // Smart pointer destructor automatically deletes mo. - } - else - // @@ What happens if new fails here? - this->activation_queue_.enqueue - (new Method_Object_name (this, new_future)); - - return new_future; - } -} - -ACE_Future<float> -Scheduler::work (float newparam, int newcount) -{ - if (this->scheduler_) - return this->scheduler_->work (newparam, newcount); - else - { - ACE_Future<float> new_future; - - if (this->thr_count () == 0) - { - ACE_Auto_Ptr<ACE_Method_Object> mo - (new Method_Object_work (this, newparam, newcount, new_future)); - mo->call (); - // Smart pointer destructor automatically deletes it. - } - else - this->activation_queue_.enqueue - (new Method_Object_work (this, newparam, newcount, new_future)); - - return new_future; - } -} - -static int -determine_iterations (void) -{ - int n_iterations; - - ACE_DEBUG ((LM_DEBUG," (%t) determining the number of iterations...\n")); - Scheduler *worker_a = new Scheduler ("worker A"); - - ACE_Time_Value tstart (ACE_OS::gettimeofday ()); - ACE_Time_Value tend (ACE_OS::gettimeofday ()); - - // Determine the number of iterations... we want so many that the - // work () takes about 1 second... - - for (n_iterations = 1; - (tend.sec () - tstart.sec ()) < 1; - n_iterations *= 2) - { - tstart = ACE_OS::gettimeofday (); - - worker_a->work (0.1, n_iterations); - - tend = ACE_OS::gettimeofday (); - } - - ACE_DEBUG ((LM_DEBUG," (%t) n_iterations %d\n", - (u_long) n_iterations)); - - worker_a->end (); - // @@ Can we safely delete worker_a here? - return n_iterations; -} - -static void -test_active_object (int n_iterations) -{ - ACE_DEBUG ((LM_DEBUG," (%t) testing active object pattern...\n")); - // A simple example for the use of the active object pattern and - // futures to return values from an active object. - - Scheduler *worker_a = new Scheduler ("worker A"); - Scheduler *worker_b = new Scheduler ("worker B"); - - // Have worker_c delegate his work to worker_a. - Scheduler *worker_c = new Scheduler ("worker C", worker_a); - - // loop 0: - // test the Schedulers when they are not active. - // now the method objects will be created but since - // there is no active thread they will also be - // immediately executed, in the "main" thread. - // loop 1: - // do the same test but with the schedulers - // activated - for (int i = 0; i < 2; i++) - { - if (i == 1) - { - worker_a->open (); - worker_b->open (); - worker_c->open (); - } - - ACE_Future<float> fresulta = worker_a->work (0.01, n_iterations); - ACE_Future<float> fresultb = worker_b->work (0.02, n_iterations); - ACE_Future<float> fresultc = worker_c->work (0.03, n_iterations); - - if (i == 0) - { - if (!fresulta.ready ()) - ACE_DEBUG ((LM_DEBUG," (%t) ERROR: worker A is should be ready!!!\n")); - if (!fresultb.ready ()) - ACE_DEBUG ((LM_DEBUG," (%t) ERROR: worker B is should be ready!!!\n")); - if (!fresultc.ready ()) - ACE_DEBUG ((LM_DEBUG," (%t) ERROR: worker C is should be ready!!!\n")); - } - - // When the workers are active we will block here until the - // results are available. - - float resulta = fresulta; - float resultb = fresultb; - float resultc = fresultc; - - ACE_Future<char *> fnamea = worker_a->name (); - ACE_Future<char *> fnameb = worker_b->name (); - ACE_Future<char *> fnamec = worker_c->name (); - - char *namea = fnamea; - char *nameb = fnameb; - char *namec = fnamec; - - ACE_DEBUG ((LM_DEBUG, " (%t) result from %s %f\n", - namea, resulta)); - ACE_DEBUG ((LM_DEBUG, " (%t) result from %s %f\n", - nameb, resultb)); - ACE_DEBUG ((LM_DEBUG, " (%t) result from %s %f\n", - namec, resultc)); - } - - ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d before end ()\n", - (u_long) scheduler_open_count)); - - worker_a->end (); - worker_b->end (); - worker_c->end (); - - ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d immediately after end ()\n", - (u_long) scheduler_open_count)); - - ACE_OS::sleep (2); - - ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d after waiting\n", - (u_long) scheduler_open_count)); - // @@ Can we safely delete worker_a, worker_b, and worker_c? -} - -static void -test_cancellation (int n_iterations) -{ - ACE_DEBUG ((LM_DEBUG," (%t) testing cancellation of a future...\n")); - - // Now test the cancelling a future. - - Scheduler *worker_a = new Scheduler ("worker A"); - worker_a->open (); - - ACE_Future<float> fresulta = worker_a->work (0.01, n_iterations); - - // save the result by copying the future - ACE_Future<float> fresultb = fresulta; - - // now we cancel the first future.. but the - // calculation will still go on... - fresulta.cancel (10.0); - - if (!fresulta.ready ()) - ACE_DEBUG ((LM_DEBUG," (%t) ERROR: future A is should be ready!!!\n")); - - float resulta = fresulta; - - ACE_DEBUG ((LM_DEBUG, " (%t) cancelled result %f\n", resulta)); - - if (resulta != 10.0) - ACE_DEBUG ((LM_DEBUG, " (%t) cancelled result should be 10.0!!\n", resulta)); - - resulta = fresultb; - - ACE_DEBUG ((LM_DEBUG, " (%t) true result %f\n", resulta)); - - worker_a->end (); - // @@ Can we safely delete worker_a here? -} - -static void -test_timeout (int n_iterations) -{ - ACE_DEBUG ((LM_DEBUG," (%t) testing timeout on waiting for the result...\n")); - Scheduler *worker_a = new Scheduler ("worker A"); - worker_a->open (); - - ACE_Future<float> fresulta = worker_a->work (0.01, 2 * n_iterations); - - // Should immediately return... and we should see an error... - ACE_Time_Value *delay = new ACE_Time_Value (1); - - float resulta; - fresulta.get (resulta, delay); - - if (fresulta.ready ()) - ACE_DEBUG ((LM_DEBUG," (%t) ERROR: future A is should not be ready!!!\n")); - else - ACE_DEBUG ((LM_DEBUG," (%t) timed out on future A\n")); - - // now we wait until we are done... - fresulta.get (resulta); - ACE_DEBUG ((LM_DEBUG, " (%t) result %f\n", resulta)); - - worker_a->end (); - // @@ Can we safely delete worker_a here? -} - -int -main (int, char *[]) -{ - int n_iterations = determine_iterations (); - - test_active_object (n_iterations); - test_cancellation (n_iterations); - test_timeout (n_iterations); - - ACE_DEBUG ((LM_DEBUG," (%t) that's all folks!\n")); - - ACE_OS::sleep (5); - return 0; -} - -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ - -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_manual_event.cpp b/examples/Threads/test_manual_event.cpp deleted file mode 100644 index 26d477fabc0..00000000000 --- a/examples/Threads/test_manual_event.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// The test shows the use of an ACE_Manual_Event to create a -// $Id$ - -// Pseudo_Barrier. Multiple threads are created which do the -// following: -// -// 1. work -// 2. synch with other threads -// 3. more work -// -// ACE_Manual_Event is use to synch with other -// threads. ACE_Manual_Event::signal() is used for broadcasting. - -#include "ace/Service_Config.h" -#include "ace/Synch.h" -#include "ace/Thread_Manager.h" - -#if defined (ACE_HAS_THREADS) -static ACE_Atomic_Op <ACE_Thread_Mutex, u_long> amount_of_work = (u_long) 0; - -class Pseudo_Barrier - // = TITLE - // A barrier class using ACE manual-reset events. - // - // = DESCRIPTION - // This is *not* a real barrier. - // Pseudo_Barrier is more like a ``one shot'' barrier. - // All waiters after the Nth waiter are allowed to go. - // The barrier does not reset after the Nth waiter. - // For an example of a real barrier, please see class ACE_Barrier. -{ -public: - Pseudo_Barrier (u_long count); - - int wait (void); - -private: - ACE_Atomic_Op <ACE_Thread_Mutex, u_long> counter_; - ACE_Manual_Event event_; -}; - -Pseudo_Barrier::Pseudo_Barrier (u_long count) - : counter_ (count) -{ -} - -int -Pseudo_Barrier::wait (void) -{ - if (--this->counter_ == 0) - return this->event_.signal (); - else - return this->event_.wait (); -} - -static void * -worker (void *arg) -{ - ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); - Pseudo_Barrier &barrier = *(Pseudo_Barrier *) arg; - - // work - ACE_DEBUG ((LM_DEBUG, "(%t) working (%d secs)\n", ++::amount_of_work)); - ACE_OS::sleep (::amount_of_work); - - // synch with everybody else - ACE_DEBUG ((LM_DEBUG, "(%t) waiting to synch with others \n")); - barrier.wait (); - - // more work - ACE_DEBUG ((LM_DEBUG, "(%t) more work (%d secs)\n", ++::amount_of_work)); - ACE_OS::sleep (amount_of_work); - - ACE_DEBUG ((LM_DEBUG, "(%t) dying \n")); - - return 0; -} - -int -main (int argc, char **argv) -{ - int n_threads = argc == 2 ? atoi (argv[1]) : 5; - - ACE_Thread_Manager &tm = *ACE_Service_Config::thr_mgr (); - - // synch object shared by all threads - Pseudo_Barrier barrier (n_threads); - - // create workers - if (tm.spawn_n (n_threads, worker, &barrier) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "thread creates for worker failed"), -1); - - // wait for all workers to exit - if (tm.wait () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "thread wait failed"), -1); - else - ACE_DEBUG ((LM_ERROR, "graceful exit\n")); - - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_process_mutex.cpp b/examples/Threads/test_process_mutex.cpp deleted file mode 100644 index fb23c8b73be..00000000000 --- a/examples/Threads/test_process_mutex.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// $Id$ - -// This program tests ACE_Process_Mutexes. To run it, open 3 or 4 -// windows and run this program in each window... - -#include "ace/Synch.h" -#include "ace/Signal.h" - -#if defined (ACE_HAS_THREADS) - -static sig_atomic_t done; - -extern "C" void -handler (int) -{ - done = 1; -} - -int -main (int argc, char *argv[]) -{ - char *name = argc > 1 ? argv[1] : "hello"; - int iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : 100; - - ACE_Process_Mutex pm (name); - - // Register a signal handler. - ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); - - for (int i = 0; i < iterations && !done; i++) - { - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquiring\n")); - if (pm.acquire () == -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "acquire failed")); - else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquired\n")); - - ACE_OS::sleep (3); - - if (pm.release () == -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "release failed")); - else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); - - if (pm.tryacquire () == -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "tryacquire failed")); - else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = tryacquire\n")); - - if (pm.release () == -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "release failed")); - else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); - } - - if (argc > 2) - pm.remove (); - return 0; -} -#else -int -main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "ACE doesn't support support threads on this platform (yet)\n"), - -1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_process_semaphore.cpp b/examples/Threads/test_process_semaphore.cpp deleted file mode 100644 index d7933897f8e..00000000000 --- a/examples/Threads/test_process_semaphore.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// $Id$ - -// This program tests ACE_Process_Semaphore. To run it, open 3 or 4 -// windows and run this program in each window... - -#include "ace/Synch.h" -#include "ace/Signal.h" - -static sig_atomic_t done; - -extern "C" void -handler (int) -{ - done = 1; -} - -int -main (int argc, char *argv[]) -{ - char *name = argc == 1 ? "hello" : argv[1]; - - ACE_Process_Semaphore pm (1, name); - - ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); - - for (int i = 0; i < 100 && !done; i++) - { - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquiring\n")); - if (pm.acquire () == -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "acquire failed")); - else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquired\n")); - - ACE_OS::sleep (3); - - if (pm.release () == -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "release failed")); - else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); - - if (pm.tryacquire () == -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "tryacquire failed")); - else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = tryacquire\n")); - - if (pm.release () == -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = %p\n", "release failed")); - else - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); - } - - if (argc > 2) - pm.remove (); - return 0; -} - diff --git a/examples/Threads/test_reader_writer.cpp b/examples/Threads/test_reader_writer.cpp deleted file mode 100644 index ef888133d83..00000000000 --- a/examples/Threads/test_reader_writer.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// This test program verifies the functionality of the ACE_OS -// $Id$ - -// implementation of readers/writer locks on Win32 and Posix pthreads. - - -#include "ace/Synch.h" -#include "ace/Thread.h" -#include "ace/Thread_Manager.h" -#include "ace/Get_Opt.h" - -#if defined (ACE_HAS_THREADS) - -// Default number of iterations. -static size_t n_iterations = 1000; - -// Default number of loops. -static size_t n_loops = 100; - -// Default number of readers. -static size_t n_readers = 6; - -// Default number of writers. -static size_t n_writers = 2; - -// Thread id of last writer. -volatile static int shared_data; - -// Lock for shared_data. -static ACE_RW_Mutex rw_mutex; - -// Count of the number of readers and writers. -ACE_Atomic_Op<ACE_Thread_Mutex, int> current_readers, current_writers; - -// Thread manager -static ACE_Thread_Manager thr_mgr; - -// Explain usage and exit. -static void -print_usage_and_die (void) -{ - ACE_DEBUG ((LM_DEBUG, - "usage: %n [-r n_readers] [-w n_writers] [-n iteration_count]\n")); - ACE_OS::exit (1); -} - -// Parse the command-line arguments and set options. -static void -parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opt (argc, argv, "r:w:n:l:"); - - int c; - - while ((c = get_opt ()) != -1) - switch (c) - { - case 'r': - n_readers = ACE_OS::atoi (get_opt.optarg); - break; - case 'w': - n_writers = ACE_OS::atoi (get_opt.optarg); - break; - case 'n': - n_iterations = ACE_OS::atoi (get_opt.optarg); - break; - case 'l': - n_loops = ACE_OS::atoi (get_opt.optarg); - break; - default: - print_usage_and_die (); - break; - } -} - -// Iterate <n_iterations> each time checking that nobody modifies the data -// while we have a read lock. - -static void * -reader (void *) -{ - ACE_Thread_Control tc (&thr_mgr); - ACE_DEBUG ((LM_DEBUG, "(%t) reader starting\n")); - - for (int iterations = 1; iterations <= n_iterations; iterations++) - { - ACE_Read_Guard<ACE_RW_Mutex> g(rw_mutex); - int n = ++current_readers; - //ACE_DEBUG ((LM_DEBUG, "(%t) I'm reader number %d\n", n)); - - if (current_writers > 0) - ACE_DEBUG ((LM_DEBUG, "(%t) writers found!!!\n")); - - int data = shared_data; - - for (int loop = 1; loop <= n_loops; loop++) - { - ACE_Thread::yield(); - if (shared_data != data) - ACE_DEBUG ((LM_DEBUG, - "(%t) somebody changed %d to %d\n", - data, shared_data)); - } - - --current_readers; - //ACE_DEBUG ((LM_DEBUG, "(%t) done with reading guarded data\n")); - - ACE_Thread::yield (); - } - return 0; -} - -// Iterate <n_iterations> each time modifying the global data -// and checking that nobody steps on it while we can write it. - -static void * -writer (void *) -{ - ACE_Thread_Control tc (&thr_mgr); - ACE_DEBUG ((LM_DEBUG, "(%t) writer starting\n")); - - for (int iterations = 1; iterations <= n_iterations; iterations++) - { - ACE_Write_Guard<ACE_RW_Mutex> g(rw_mutex); - - ++current_writers; - //ACE_DEBUG ((LM_DEBUG, "(%t) writing to guarded data\n")); - - if (current_writers > 1) - ACE_DEBUG ((LM_DEBUG, "(%t) other writers found!!!\n")); - - if (current_readers > 0) - ACE_DEBUG ((LM_DEBUG, "(%t) readers found!!!\n")); - - int self = (int) ACE_Thread::self (); - shared_data = self; - - for (int loop = 1; loop <= n_loops; loop++) - { - ACE_Thread::yield(); - if (shared_data != self) - ACE_DEBUG ((LM_DEBUG, "(%t) somebody wrote on my data %d\n", shared_data)); - } - - --current_writers; - - //ACE_DEBUG ((LM_DEBUG, "(%t) done with guarded data\n")); - ACE_Thread::yield (); - } - return 0; -} - -// Spawn off threads. - -int main (int argc, char *argv[]) -{ - ACE_LOG_MSG->open (argv[0]); - parse_args (argc, argv); - - current_readers = 0; // Possibly already done - current_writers = 0; // Possibly already done - - ACE_DEBUG ((LM_DEBUG, "(%t) main thread starting\n")); - - if (thr_mgr.spawn_n (n_readers, reader, 0, THR_NEW_LWP) == -1 || - thr_mgr.spawn_n (n_writers, writer, 0, THR_NEW_LWP) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); - - thr_mgr.wait (); - - ACE_DEBUG ((LM_DEBUG, "(%t) exiting main thread\n")); - return 0; -} - -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ - -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ - diff --git a/examples/Threads/test_recursive_mutex.cpp b/examples/Threads/test_recursive_mutex.cpp deleted file mode 100644 index 1cc2892b2a8..00000000000 --- a/examples/Threads/test_recursive_mutex.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// $Id$ - -// This test program verifies the functionality of the ACE_OS -// implementation of recursive mutexes on Win32 and Posix pthreads. - -#include "ace/Service_Config.h" -#include "ace/Get_Opt.h" -#include "ace/Synch.h" - -#if defined (ACE_HAS_THREADS) - -// Total number of iterations. -static size_t n_iterations = 1000; -static size_t n_threads = 4; - -// Explain usage and exit. -static void -print_usage_and_die (void) -{ - ACE_DEBUG ((LM_DEBUG, - "usage: %n [-t n_threads] [-n iteration_count]\n")); - ACE_OS::exit (1); -} - -// Parse the command-line arguments and set options. - -static void -parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opt (argc, argv, "n:t:"); - - int c; - - while ((c = get_opt ()) != -1) - switch (c) - { - case 'n': - n_iterations = ACE_OS::atoi (get_opt.optarg); - break; - case 't': - n_threads = ACE_OS::atoi (get_opt.optarg); - break; - default: - print_usage_and_die (); - break; - } -} - -static void -recursive_worker (size_t nesting_level, - ACE_Recursive_Thread_Mutex *rm) -{ - if (nesting_level < n_iterations) - { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) = trying to acquire, nesting = %d, thread id = %u\n", - rm->get_nesting_level (), rm->get_thread_id ())); - { - // This illustrates the use of the ACE_Guard<LOCK> with an - // ACE_Recursive_Thread_Mutex. - ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, *rm); - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) = acquired, nesting = %d, thread id = %u\n", - rm->get_nesting_level (), rm->get_thread_id ())); - - recursive_worker (nesting_level + 1, rm); - } - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) = released, nesting = %d, thread id = %u\n", - rm->get_nesting_level (), rm->get_thread_id ())); - } -} - -static void * -worker (void *arg) -{ - ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); - - ACE_Recursive_Thread_Mutex *rm = (ACE_Recursive_Thread_Mutex *) arg; - - recursive_worker (0, rm); - return 0; -} - -int -main (int argc, char *argv[]) -{ - ACE_Service_Config daemon (argv[0]); - - parse_args (argc, argv); - ACE_Recursive_Thread_Mutex rm; - - ACE_Service_Config::thr_mgr ()->spawn_n (n_threads, - ACE_THR_FUNC (worker), - (void *) &rm); - - ACE_Service_Config::thr_mgr ()->wait (); - return 0; -} -#else -int -main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "ACE doesn't support support process mutexes on this platform (yet)\n"), - -1); -} -#endif /* ACE_WIN32 */ diff --git a/examples/Threads/test_task.cpp b/examples/Threads/test_task.cpp deleted file mode 100644 index 7cd7976d2bb..00000000000 --- a/examples/Threads/test_task.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// This test program illustrates how the ACE barrier synchronization -// $Id$ - -// mechanisms work in conjunction with the ACE_Task and the -// ACE_Thread_Manager. It is instructive to compare this with the -// test_barrier.cpp test to see how they differ. - -#include "ace/Task.h" -#include "ace/Service_Config.h" -#include "ace/Log_Msg.h" - -#if defined (ACE_HAS_THREADS) - -#include "ace/Task.h" - -class Barrier_Task : public ACE_Task<ACE_MT_SYNCH> -{ -public: - Barrier_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int n_iterations); - - virtual int svc (void); - // Iterate <n_iterations> time printing off a message and "waiting" - // for all other threads to complete this iteration. - -private: - ACE_Barrier barrier_; - // Reference to the tester barrier. This controls each - // iteration of the tester function running in every thread. - - int n_iterations_; - // Number of iterations to run. - - // = Not needed for this test. - virtual int open (void *) { return 0; } - virtual int close (u_long) { return 0; } - virtual int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } -}; - -Barrier_Task::Barrier_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int n_iterations) - : ACE_Task<ACE_MT_SYNCH> (thr_mgr), - barrier_ (n_threads), - n_iterations_ (n_iterations) -{ - // Create worker threads. - if (this->activate (THR_NEW_LWP, n_threads) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); -} - -// Iterate <n_iterations> time printing off a message and "waiting" -// for all other threads to complete this iteration. - -int -Barrier_Task::svc (void) -{ - // Note that the ACE_Task::svc_run() method automatically adds us to - // the Thread_Manager when the thread begins. - - for (int iterations = 1; - iterations <= this->n_iterations_; - iterations++) - { - ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d\n", iterations)); - - // Block until all other threads have waited, then continue. - this->barrier_.wait (); - } - - // Note that the ACE_Task::svc_run() method automatically removes us - // from the Thread_Manager when the thread exits. - - return 0; -} - -// Default number of threads to spawn. -static const int DEFAULT_ITERATIONS = 5; - -int -main (int argc, char *argv[]) -{ - int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; - int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; - - Barrier_Task barrier_task (ACE_Service_Config::thr_mgr (), - n_threads, - n_iterations); - - // Wait for all the threads to reach their exit point. - ACE_Service_Config::thr_mgr ()->wait (); - - ACE_DEBUG ((LM_DEBUG, "(%t) done\n")); - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_task_four.cpp b/examples/Threads/test_task_four.cpp deleted file mode 100644 index 64209cb3430..00000000000 --- a/examples/Threads/test_task_four.cpp +++ /dev/null @@ -1,248 +0,0 @@ -// $Id$ - -// The following test was written by Hamutal Yanay & Ari Erev's -// (Ari_Erev@comverse.com). -// -// This test program test enhancements to the thread_manager and task -// classes. The purpose of these enhancements was to allow the -// thread_manager to recognize the concept of an ACE_Task and to be -// able to group ACE_Tasks in groups. -// -// There are two main ACE_Tasks in this sample: -// -// Invoker_Task - is run from main (). It's purpose is to run a number of -// ACE_Tasks of type Worker_Task. The number can be specified -// on the command line. -// After starting the tasks, the Invoker_Task groups all the tasks -// in one group and then uses the -// num_tasks_in_group () to find out if the real number of tasks -// that are now running (should be the same as the number of tasks -// started). -// It also, suspends and resumes all the threads in the group to -// test the suspend_grp () and resume_grp () methods. -// Then it waits for all the tasks to end. -// Worker_Task - ACE_Tasks that are started by the Invoker_Task. -// Each Worker_Task can start a number of threads. -// The Worker_Task threads perform some work (iteration). The number -// of the iterations can be specified on the command line. -// -// The command line syntax is: -// -// test_task [num_tasks] [num_threads] [num_iterations] - -#include "ace/Task.h" -#include "ace/Service_Config.h" - - -#if defined (ACE_HAS_THREADS) - -#include "ace/Task.h" - -class Invoker_Task : public ACE_Task<ACE_MT_SYNCH> -{ -public: - Invoker_Task (ACE_Thread_Manager *thr_mgr, - int n_tasks, - int n_threads, - int n_iterations); - virtual int svc (void); - // creats <n_tasks> and wait for them to finish - -private: - int n_tasks_; - // Number of tasks to start. - int n_threads_; - // Number of threads per task. - int n_iterations_; - // Number of iterations per thread. - - // = Not needed for this test. - virtual int open (void *) { return 0; } - virtual int close (u_long) { return 0; } - virtual int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } -}; - -class Worker_Task : public ACE_Task<ACE_MT_SYNCH> -{ -public: - Worker_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int n_iterations); - virtual int svc (void); - // Does a small work... - virtual int open (void * = NULL); -private: - static int workers_count_; - int index_; - int n_threads_; - int n_iterations_; - - // = Not needed for this test. - virtual int close (u_long) { return 0; } - virtual int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } -}; - -int Worker_Task::workers_count_ = 1; - -Worker_Task::Worker_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int n_iterations) - : n_threads_ (n_threads), - n_iterations_ (n_iterations), - ACE_Task<ACE_MT_SYNCH> (thr_mgr) -{ - index_ = workers_count_++; -} - -int -Worker_Task::open (void *) -{ - // Create worker threads. - int rc = this->activate (THR_NEW_LWP, n_threads_, 0, 0, -1, this); - - if (rc == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); - - return rc; -} - -int -Worker_Task::svc (void) -{ - ACE_DEBUG ((LM_DEBUG, " (%t) in worker %d\n", index_)); - - for (int iterations = 1; - iterations <= this->n_iterations_; - iterations++) - { - ACE_DEBUG ((LM_DEBUG, " (%t) in iteration %d\n", iterations)); - ACE_OS::sleep (0); - } - - ACE_DEBUG ((LM_DEBUG, " (%t) worker %d ends\n", index_)); - - return 0; -} - -Invoker_Task::Invoker_Task (ACE_Thread_Manager *thr_mgr, - int n_tasks, - int n_threads, - int n_iterations) - : n_tasks_ (n_tasks), - n_threads_ (n_threads), - n_iterations_ (n_iterations), - ACE_Task<ACE_MT_SYNCH> (thr_mgr) -{ - // Create worker threads. - if (this->activate (THR_NEW_LWP, 1, 0, 0, -1, this) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); -} - -// Iterate <n_iterations> time printing off a message and "waiting" -// for all other threads to complete this iteration. - -int -Invoker_Task::svc (void) -{ - // Note that the ACE_Task::svc_run () method automatically adds us to - // the Thread_Manager when the thread begins. - - ACE_Thread_Manager *thr_mgr = ACE_Service_Config::thr_mgr (); - Worker_Task **pTask = new Worker_Task* [n_tasks_]; - - for (int task = 0; - task < this->n_tasks_; - task++) - { - ACE_DEBUG ((LM_DEBUG, " (%t) in task %d\n", task+1)); - pTask[task] = new Worker_Task (thr_mgr, n_threads_, n_iterations_); - pTask[task]->open (); - } - - // Set all tasks to be one group - ACE_DEBUG ((LM_DEBUG, " (%t) setting tasks group id\n")); - for (task = 0; - task < this->n_tasks_; - task++) - if (thr_mgr->set_grp (pTask[task], 1) == -1) - ACE_ERROR ((LM_DEBUG, " (%t) %p\n", "set_grp")); - - int nTasks = thr_mgr->num_tasks_in_group (1); - cout << "Number of tasks in group 1: " << nTasks << endl; - - // Wait for 1 second and then suspend every thread in the group. - ACE_OS::sleep (1); - ACE_DEBUG ((LM_DEBUG, " (%t) suspending group\n")); - if (thr_mgr->suspend_grp (1) == -1) - ACE_ERROR ((LM_DEBUG, " (%t) %p\n", "suspend_grp")); - - // Wait for 5 more second and then resume every thread in the - // group. - ACE_OS::sleep (ACE_Time_Value (5)); - - // @QTSK This ACE_DEBUG statement blows us away! can't understand why - ACE_DEBUG ((LM_DEBUG, " (%t) resuming group\n")); - if (thr_mgr->resume_grp (1) == -1) - ACE_ERROR ((LM_DEBUG, " (%t) %p\n", "resume_grp")); - - - // Wait for all the tasks to reach their exit point. - thr_mgr->wait (); - - // Note that the ACE_Task::svc_run () method automatically removes us - // from the Thread_Manager when the thread exits. - - return 0; -} - -// Default number of tasks and iterations. -static const int DEFAULT_TASKS = 4; -static const int DEFAULT_ITERATIONS = 5; - -int -main (int argc, char *argv[]) -{ - int n_tasks = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_TASKS; - int n_threads = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_THREADS; - int n_iterations = argc > 3 ? ACE_OS::atoi (argv[3]) : DEFAULT_ITERATIONS; - - // Since ACE_Thread_Manager can only wait for all threads, we'll have - // special manager for the Invoker_Task. - ACE_Thread_Manager invoker_manager; - - Invoker_Task invoker (&invoker_manager, - n_tasks, - n_threads, - n_iterations); - - // Wait for 1 second and then suspend the invoker task - ACE_OS::sleep (1); - ACE_DEBUG ((LM_DEBUG, " (%t) suspending invoker task\n")); - - if (invoker_manager.suspend_task (&invoker) == -1) - ACE_ERROR ((LM_DEBUG, " (%t) %p\n", "suspend_task")); - - // Wait for 5 more second and then resume the invoker task. - ACE_OS::sleep (ACE_Time_Value (5)); - - // @QTSK This ACE_DEBUG statement blows us away! can't understand why - ACE_DEBUG ((LM_DEBUG, " (%t) resuming invoker task\n")); - if (invoker_manager.resume_task (&invoker) == -1) - ACE_ERROR ((LM_DEBUG, " (%t) %p\n", "resume_task")); - - - // Wait for all the threads to reach their exit point. - invoker_manager.wait (); - - // @QTSK This ACE_DEBUG statement blows us away! can't understand why - ACE_DEBUG ((LM_DEBUG, " (%t) done\n")); - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_task_one.cpp b/examples/Threads/test_task_one.cpp deleted file mode 100644 index d0a8a12e6c4..00000000000 --- a/examples/Threads/test_task_one.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// This test program illustrates how the ACE barrier synchronization -// $Id$ - -// mechanisms work in conjunction with the ACE_Task and the -// ACE_Thread_Manager. It is instructive to compare this with the -// test_barrier.cpp test to see how they differ. - -#include "ace/Task.h" -#include "ace/Service_Config.h" - - -#if defined (ACE_HAS_THREADS) - -#include "ace/Task.h" - -class Barrier_Task : public ACE_Task<ACE_MT_SYNCH> -{ -public: - Barrier_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int n_iterations); - - virtual int svc (void); - // Iterate <n_iterations> time printing off a message and "waiting" - // for all other threads to complete this iteration. - -private: - ACE_Barrier barrier_; - // Reference to the tester barrier. This controls each - // iteration of the tester function running in every thread. - - int n_iterations_; - // Number of iterations to run. - - // = Not needed for this test. - virtual int open (void *) { return 0; } - virtual int close (u_long) { return 0; } - virtual int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } -}; - -Barrier_Task::Barrier_Task (ACE_Thread_Manager *thr_mgr, - int n_threads, - int n_iterations) - : ACE_Task<ACE_MT_SYNCH> (thr_mgr), - barrier_ (n_threads), - n_iterations_ (n_iterations) -{ - // Create worker threads. - if (this->activate (THR_NEW_LWP, n_threads) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); -} - -// Iterate <n_iterations> time printing off a message and "waiting" -// for all other threads to complete this iteration. - -int -Barrier_Task::svc (void) -{ - // Note that the ACE_Task::svc_run() method automatically adds us to - // the Thread_Manager when the thread begins. - - for (int iterations = 1; - iterations <= this->n_iterations_; - iterations++) - { - ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d\n", iterations)); - - // Block until all other threads have waited, then continue. - this->barrier_.wait (); - } - - // Note that the ACE_Task::svc_run() method automatically removes us - // from the Thread_Manager when the thread exits. - - return 0; -} - -// Default number of threads to spawn. -static const int DEFAULT_ITERATIONS = 5; - -int -main (int argc, char *argv[]) -{ - int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; - int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; - - Barrier_Task barrier_task (ACE_Service_Config::thr_mgr (), - n_threads, - n_iterations); - - // Wait for all the threads to reach their exit point. - ACE_Service_Config::thr_mgr ()->wait (); - - ACE_DEBUG ((LM_DEBUG, "(%t) done\n")); - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_task_three.cpp b/examples/Threads/test_task_three.cpp deleted file mode 100644 index c6ad69511b5..00000000000 --- a/examples/Threads/test_task_three.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// $Id$ - -// Exercise more tests for the ACE Tasks. This also shows off some -// Interesting uses of the ACE Log_Msg's ability to print to ostreams. -// BTW, make sure that you set the out_stream in *every* thread that -// you want to have write to the output file, i.e.: -// -// -// if (out_stream) -// { -// ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); -// ACE_LOG_MSG->msg_ostream (out_stream); -// } - -#include <fstream.h> -#include "ace/Reactor.h" -#include "ace/Service_Config.h" -#include "ace/Task.h" - - -#if defined (ACE_HAS_THREADS) - -static ofstream *out_stream = 0; - -static const int NUM_INVOCATIONS = 100; -static const int TASK_COUNT = 130; - -class Test_Task : public ACE_Task<ACE_MT_SYNCH> -{ -public: - Test_Task (void); - ~Test_Task (void); - - virtual int open (void *args = 0); - virtual int close (u_long flags = 0); - virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0); - virtual int svc (void); - - virtual int handle_input (ACE_HANDLE fd); - - ACE_Reactor *r_; - int handled_; - static int current_count_; - static int done_cnt_; -}; - -int Test_Task::current_count_ = 0; -int Test_Task::done_cnt_ = 0; - -static ACE_Thread_Mutex lock_; - -Test_Task::Test_Task (void) -{ - ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); - - this->handled_ = 0; - Test_Task::current_count_++; - ACE_DEBUG ((LM_DEBUG, - "Test_Task constructed, current_count_ = %d\n", - Test_Task::current_count_)); -} - -Test_Task::~Test_Task (void) -{ - ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); - - ACE_DEBUG ((LM_DEBUG, "Test_Task destroyed, current_count_ = %d\n", - Test_Task::current_count_)); -} - -int -Test_Task::open (void *args) -{ - r_ = (ACE_Reactor *) args; - return ACE_Task<ACE_MT_SYNCH>::activate (THR_NEW_LWP); -} - -int -Test_Task::close (u_long) -{ - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock_, -1); - - Test_Task::current_count_--; - ACE_DEBUG ((LM_DEBUG, "Test_Task::close () current_count_ = %d.\n", - Test_Task::current_count_)); - return 0; -} - -int -Test_Task::put (ACE_Message_Block *, ACE_Time_Value *) -{ - return 0; -} - -Test_Task::svc (void) -{ - // Every thread must register the same stream to write to file. - if (out_stream) - { - ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); - ACE_LOG_MSG->msg_ostream (out_stream); - } - - for (int index = 0; index < NUM_INVOCATIONS; index++) - { - ACE_OS::thr_yield (); - - if (r_->notify (this, ACE_Event_Handler::READ_MASK)) - { - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock_, -1); - - ACE_DEBUG ((LM_DEBUG, "Test_Task: error notifying reactor!\n")); - } - } - - ACE_DEBUG ((LM_DEBUG, " (%t) returning from svc ()\n")); - return 0; -} - -int -Test_Task::handle_input (ACE_HANDLE) -{ - this->handled_++; - - if (this->handled_ == NUM_INVOCATIONS) - { - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock_, -1); - Test_Task::done_cnt_++; - ACE_DEBUG ((LM_DEBUG, - " (%t) Test_Task: handle_input! done_cnt_ = %d.\n", - Test_Task::done_cnt_)); - } - - ACE_OS::thr_yield (); - return -1; -} - -static void * -dispatch (void *arg) -{ - // every thread must register the same stream to write to file - if (out_stream) - { - ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); - ACE_LOG_MSG->msg_ostream (out_stream); - } - - ACE_DEBUG ((LM_DEBUG, " (%t) Dispatcher Thread started!\n")); - ACE_Reactor *r = (ACE_Reactor *) arg; - int result; - - r->owner (ACE_OS::thr_self ()); - - while (1) - { - result = r->handle_events (); - if (result <= 0) - ACE_DEBUG ((LM_DEBUG, "Dispatch: handle_events (): %d", result)); - } - - return 0; -} - -extern "C" void -handler (int) -{ - *out_stream << flush; - out_stream->close (); - ACE_OS::exit (42); -} - -int -main (int argc, char **argv) -{ - if (argc > 1) - { - // Send output to file. - out_stream = new ofstream ("test_task_three.out", ios::trunc|ios::out); - ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); - ACE_LOG_MSG->msg_ostream (out_stream); - } - - // Register a signal handler. - ACE_Sig_Action sa (ACE_SignalHandler (handler), SIGINT); - - ACE_Reactor *reactor1 = ACE_Service_Config::reactor (); - ACE_Reactor *reactor2 = new ACE_Reactor (); - - Test_Task t1[TASK_COUNT]; - Test_Task t2[TASK_COUNT]; - - ACE_Thread::spawn (ACE_THR_FUNC (dispatch), reactor2); - - reactor1->owner (ACE_OS::thr_self ()); - - for (int index = 0; index < TASK_COUNT; index++) - { - t1[index].open (reactor1); - t2[index].open (reactor2); - } - - ACE_OS::sleep (3); - - for (;;) - { - ACE_Time_Value timeout (2); - - if (reactor1->handle_events (timeout) <= 0) - { - if (errno == ETIME) - { - ACE_DEBUG ((LM_DEBUG, "no activity within 2 seconds, shutting down\n")); - break; - } - else - ACE_ERROR ((LM_ERROR, "%p error handling events\n", "main")); - } - } - - return 0; -} - -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_task_two.cpp b/examples/Threads/test_task_two.cpp deleted file mode 100644 index 9f25962c795..00000000000 --- a/examples/Threads/test_task_two.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// $Id$ - -// Exercise more tests for the ACE Tasks. This test can spawn off -// zillions of tasks and then wait for them using both polling and the -// ACE Thread Manager. - -#include "ace/Task.h" - -#include "ace/Service_Config.h" -#include "ace/Synch.h" - -#if defined (ACE_HAS_THREADS) - -typedef ACE_Atomic_Op<ACE_Thread_Mutex, u_long> ATOMIC_INT; - -static u_long zero = 0; -static ATOMIC_INT task_count (zero); -static ATOMIC_INT max_count (zero); -static ATOMIC_INT wait_count (zero); - -static u_long n_threads = 0; - -// Default number of tasks. -static const int default_threads = ACE_DEFAULT_THREADS; - -// Default number of times to run the test. -static const int default_iterations = 1000; - -class Task_Test : public ACE_Task<ACE_MT_SYNCH> -{ -public: - virtual int open (void *args = 0); - virtual int close (u_long flags = 0); - virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0); - virtual int svc (void); - -private: - static ACE_Thread_Mutex lock_; -}; - -ACE_Thread_Mutex Task_Test::lock_; - -int -Task_Test::open (void *) -{ - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Task_Test::lock_, -1); - - task_count++; - ACE_DEBUG ((LM_DEBUG, "(%t) creating Task_Test, task count = %d\n", - (u_long) task_count)); - - return this->activate (THR_BOUND); -} - -int -Task_Test::close (u_long) -{ - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Task_Test::lock_, -1); - - task_count--; - ACE_DEBUG ((LM_DEBUG, "(%t) destroying Task_Test, task count = %d\n", - (u_long) task_count)); - wait_count--; -// delete this; - return 0; -} - -int -Task_Test::put (ACE_Message_Block *, - ACE_Time_Value *) -{ - return 0; -} - -int -Task_Test::svc (void) -{ - wait_count++; - max_count++; - - ACE_DEBUG ((LM_DEBUG, "(%t) svc: waiting\n")); - - for (;;) - if (max_count >= n_threads) - break; - else - ACE_Thread::yield (); - - ACE_DEBUG ((LM_DEBUG, "(%t) svc: finished waiting\n")); - return 0; -} - -int -main (int argc, char *argv[]) -{ - n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : default_threads; - int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : default_iterations; - - Task_Test **task_array = new Task_Test *[n_threads]; - - for (int i = 1; i <= n_iterations; i++) - { - ACE_DEBUG ((LM_DEBUG, "(%t) iteration = %d, max_count %d\n", - i, (u_long) max_count)); - max_count = 0; - - ACE_DEBUG ((LM_DEBUG, "(%t) starting %d task%s\n", - n_threads, n_threads == 1 ? "" : "s")); - - // Launch the new tasks. - for (int j = 0; j < n_threads; j++) - { - task_array[j] = new Task_Test; - // Activate the task, i.e., make it an active object. - task_array[j]->open (); - } - - // Wait for initialization to kick in. - while (max_count == 0) - ACE_Thread::yield (); - - ACE_DEBUG ((LM_DEBUG, "(%t) waiting for threads to finish\n")); - - // Wait for the threads to finish this iteration. - while (max_count != n_threads && wait_count != 0) - ACE_Thread::yield (); - - ACE_DEBUG ((LM_DEBUG, "(%t) iteration %d finished, max_count %d, wait_count %d, waiting for tasks to exit\n", - i, (u_long) max_count, (u_long) wait_count)); - - // Wait for all the tasks to exit. - ACE_Service_Config::thr_mgr ()->wait (); - - // Delete the existing tasks. - for (int k = 0; k < n_threads; k++) - delete task_array[k]; - } - - delete [] task_array; - - ACE_DEBUG ((LM_DEBUG, "(%t) shutting down the test\n")); - return 0; -} - -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ - -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_thread_manager.cpp b/examples/Threads/test_thread_manager.cpp deleted file mode 100644 index 73029d70d88..00000000000 --- a/examples/Threads/test_thread_manager.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// $Id$ - -// Test out the group management mechanisms provided by the -// ACE_Thread_Manager, including the group signal handling, group -// suspension and resumption, and cooperative thread cancellation -// mechanisms. - -#include "ace/Service_Config.h" -#include "ace/Thread_Manager.h" - -#if defined (ACE_HAS_THREADS) - -extern "C" void -handler (int signum) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) received signal %d\n", signum)); -} - -static void * -worker (int iterations) -{ - ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); - - for (int i = 0; i < iterations; i++) - { - if ((i % 1000) == 0) - { - ACE_DEBUG ((LM_DEBUG, - "(%t) checking cancellation before iteration %d!\n", - i)); - - if (ACE_Service_Config::thr_mgr ()->testcancel (ACE_Thread::self ()) != 0) - { - ACE_DEBUG ((LM_DEBUG, - "(%t) has been cancelled before iteration %d!\n", - i)); - break; - } - } - } - - // Destructor removes thread from Thread_Manager. - return 0; -} - -static const int DEFAULT_THREADS = ACE_DEFAULT_THREADS; -static const int DEFAULT_ITERATIONS = 100000; - -int -main (int argc, char *argv[]) -{ - ACE_Service_Config daemon; - - daemon.open (argv[0]); - - // Register a signal handler. - ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); - - int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_THREADS; - int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; - - ACE_Thread_Manager *thr_mgr = ACE_Service_Config::thr_mgr (); - - int grp_id = thr_mgr->spawn_n (n_threads, ACE_THR_FUNC (worker), - (void *) n_iterations, - THR_NEW_LWP | THR_DETACHED); - - // Wait for 1 second and then suspend every thread in the group. - ACE_OS::sleep (1); - ACE_DEBUG ((LM_DEBUG, "(%t) suspending group\n")); - if (thr_mgr->suspend_grp (grp_id) == -1) - ACE_ERROR ((LM_DEBUG, "(%t) %p\n", "suspend_grp")); - - // Wait for 1 more second and then resume every thread in the - // group. - ACE_OS::sleep (ACE_Time_Value (1)); - ACE_DEBUG ((LM_DEBUG, "(%t) resuming group\n")); - if (thr_mgr->resume_grp (grp_id) == -1) - ACE_ERROR ((LM_DEBUG, "(%t) %p\n", "resume_grp")); - - // Wait for 1 more second and then send a SIGINT to every thread in - // the group. - ACE_OS::sleep (ACE_Time_Value (1)); - ACE_DEBUG ((LM_DEBUG, "(%t) signaling group\n")); - if (thr_mgr->kill_grp (grp_id, SIGINT) == -1) - ACE_ERROR ((LM_DEBUG, "(%t) %p\n", "kill_grp")); - - // Wait for 1 more second and then cancel all the threads. - ACE_OS::sleep (ACE_Time_Value (1)); - ACE_DEBUG ((LM_DEBUG, "(%t) cancelling group\n")); - if (thr_mgr->cancel_grp (grp_id) == -1) - ACE_ERROR ((LM_DEBUG, "(%t) %p\n", "cancel_grp")); - - // Perform a barrier wait until all the threads have shut down. - thr_mgr->wait (); - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_thread_pool.cpp b/examples/Threads/test_thread_pool.cpp deleted file mode 100644 index 68741156b83..00000000000 --- a/examples/Threads/test_thread_pool.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// This test program illustrates how the ACE task synchronization -// $Id$ - -// mechanisms work in conjunction with the ACE_Task and the -// ACE_Thread_Manager. If the manual flag is not set input comes from -// stdin until the user enters a return only. This stops all workers -// via a message block of length 0. This is an alternative shutdown of -// workers compared to queue deactivate. -// -// This code is original based on a test program written by Karlheinz -// Dorn. It was modified to utilize more "ACE" features by Doug Schmidt. - -#include "ace/Task.h" -#include "ace/Service_Config.h" - -#include "ace/Task.h" - -#if defined (ACE_HAS_THREADS) - -// Number of iterations to run the test. -static size_t n_iterations = 100; - -class Thread_Pool : public ACE_Task<ACE_MT_SYNCH> -{ -public: - Thread_Pool (ACE_Thread_Manager *thr_mgr, int n_threads); - - virtual int svc (void); - // Iterate <n_iterations> time printing off a message and "waiting" - // for all other threads to complete this iteration. - - virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv=0); - // This allows the producer to pass messages to the <Thread_Pool>. - -private: - virtual int close (u_long); - - // = Not needed for this test. - virtual int open (void *) { return 0; } -}; - -int -Thread_Pool::close (u_long) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) close of worker\n")); - return 0; -} - -Thread_Pool::Thread_Pool (ACE_Thread_Manager *thr_mgr, - int n_threads) - : ACE_Task<ACE_MT_SYNCH> (thr_mgr) -{ - // Create worker threads. - if (this->activate (THR_NEW_LWP, n_threads) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); -} - -// Simply enqueue the Message_Block into the end of the queue. - -int -Thread_Pool::put (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - return this->putq (mb, tv); -} - -// Iterate <n_iterations> time printing off a message and "waiting" -// for all other threads to complete this iteration. - -int -Thread_Pool::svc (void) -{ - // Note that the ACE_Task::svc_run () method automatically adds us to - // the Thread_Manager when the thread begins. - - int result = 0; - int count = 1; - - // Keep looping, reading a message out of the queue, until we get a - // message with a length == 0, which signals us to quit. - - for (;; count++) - { - ACE_Message_Block *mb; - - ACE_DEBUG ((LM_DEBUG, "(%t) in iteration %d before getq ()\n", count)); - - if (this->getq (mb) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%t) in iteration %d, got result -1, exiting\n", count)); - break; - } - - int length = mb->length (); - - if (length > 0) - ACE_DEBUG ((LM_DEBUG, - "(%t) in iteration %d, length = %d, text = \"%*s\"\n", - count, length, length - 1, mb->rd_ptr ())); - - // We're responsible for deallocating this. - delete mb; - - if (length == 0) - { - ACE_DEBUG ((LM_DEBUG, - "(%t) in iteration %d, got NULL message, exiting\n", - count)); - break; - } - } - - // Note that the ACE_Task::svc_run () method automatically removes - // us from the Thread_Manager when the thread exits. - return 0; -} - -static void -produce (Thread_Pool &thread_pool) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) producer start, dumping the Thread_Pool\n")); - thread_pool.dump (); - - for (int n;;) - { - // Allocate a new message. - ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); - -#if defined (manual) - ACE_DEBUG ((LM_DEBUG, - "(%t) press chars and enter to put a new message into task queue...")); - n = ACE_OS::read (ACE_STDIN, mb->rd_ptr (), mb->size ()); -#else // Automatically generate messages. - static int count = 0; - - ACE_OS::sprintf (mb->rd_ptr (), "%d\n", count); - - n = ACE_OS::strlen (mb->rd_ptr ()); - - if (count == n_iterations) - n = 1; // Indicate that we need to shut down. - else - count++; - - if (count == 0 || (count % 20 == 0)) - ACE_OS::sleep (1); -#endif /* manual */ - if (n > 1) - { - // Send a normal message to the waiting threads and continue - // producing. - mb->wr_ptr (n); - - // Pass the message to the Thread_Pool. - if (thread_pool.put (mb) == -1) - ACE_ERROR ((LM_ERROR, " (%t) %p\n", "put")); - } - else - { - // Send a shutdown message to the waiting threads and exit. - ACE_DEBUG ((LM_DEBUG, "\n(%t) start loop, dump of task:\n")); - thread_pool.dump (); - - for (int i = thread_pool.thr_count (); i > 0; i--) - { - ACE_DEBUG ((LM_DEBUG, - "(%t) EOF, enqueueing NULL block for thread = %d\n", - i)); - - // Enqueue a NULL message to flag each consumer to - // shutdown. - if (thread_pool.put (new ACE_Message_Block) == -1) - ACE_ERROR ((LM_ERROR, " (%t) %p\n", "put")); - } - - ACE_DEBUG ((LM_DEBUG, "\n(%t) end loop, dump of task:\n")); - thread_pool.dump (); - break; - } - } -} - -int -main (int argc, char *argv[]) -{ - int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_THREADS; - n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : n_iterations; - - ACE_DEBUG ((LM_DEBUG, "(%t) argc = %d, threads = %d\n", - argc, n_threads)); - - // Create the worker tasks. - Thread_Pool thread_pool (ACE_Service_Config::thr_mgr (), - n_threads); - - // Create work for the worker tasks to process in their own threads. - produce (thread_pool); - - // Wait for all the threads to reach their exit point. - - ACE_DEBUG ((LM_DEBUG, "(%t) waiting with thread manager...\n")); - ACE_Service_Config::thr_mgr ()->wait (); - - ACE_DEBUG ((LM_DEBUG, "(%t) destroying worker tasks and exiting...\n")); - return 0; -} -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_thread_specific.cpp b/examples/Threads/test_thread_specific.cpp deleted file mode 100644 index f7a4f6dccf3..00000000000 --- a/examples/Threads/test_thread_specific.cpp +++ /dev/null @@ -1,219 +0,0 @@ -#include "ace/Service_Config.h" -// $Id$ - -#include "ace/Synch.h" - -#if defined (ACE_HAS_THREADS) - -// Define a class that will be stored in thread-specific data. Note -// that as far as this class is concerned it's just a regular C++ -// class. The ACE_TSS wrapper transparently ensures that -// objects of this class will be placed in thread-specific storage. -// All calls on ACE_TSS::operator->() are delegated to the -// appropriate method in the Errno class. - -class Errno -{ -public: - int error (void) { return this->errno_; } - void error (int i) { this->errno_ = i; } - - int line (void) { return this->lineno_; } - void line (int l) { this->lineno_ = l; } - - // Errno::flags_ is a static variable, so we've got to protect it - // with a mutex since it isn't kept in thread-specific storage. - int flags (void) - { - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Errno::lock_, -1); - - return Errno::flags_; - } - - void flags (int f) - { - ACE_GUARD (ACE_Thread_Mutex, ace_mon, Errno::lock_); - - Errno::flags_ = f; - } - -private: - // = errno_ and lineno_ will be thread-specific data so they don't - // need a lock. - int errno_; - int lineno_; - - static int flags_; -#if defined (ACE_HAS_THREADS) - // flags_ needs a lock. - static ACE_Thread_Mutex lock_; -#endif /* ACE_HAS_THREADS */ -}; - -// Static variables. -ACE_MT (ACE_Thread_Mutex Errno::lock_); -int Errno::flags_; - -// This is our thread-specific error handler... -static ACE_TSS<Errno> TSS_Error; - -#if defined (ACE_HAS_THREADS) -// Serializes output via cout. -static ACE_Thread_Mutex lock; - -typedef ACE_TSS_Guard<ACE_Thread_Mutex> GUARD; -#else -// Serializes output via cout. -static ACE_Null_Mutex lock; - -typedef ACE_Guard<ACE_Null_Mutex> GUARD; -#endif /* ACE_HAS_THREADS */ - -static void -cleanup (void *ptr) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) in cleanup, ptr = %x\n", ptr)); - - delete ptr; -} - -// This worker function is the entry point for each thread. - -static void * -worker (void *c) -{ - ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); - int count = int (c); - - ACE_thread_key_t key = 0; - int *ip = 0; - - // Make one key that will be available when the thread exits so that - // we'll have something to cleanup! - - if (ACE_OS::thr_keycreate (&key, cleanup) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); - - ip = new int; - - if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - for (int i = 0; i < count; i++) - { - if (ACE_OS::thr_keycreate (&key, cleanup) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); - - ip = new int; - - ACE_DEBUG ((LM_DEBUG, "(%t) in worker 1, key = %d, ip = %x\n", key, ip)); - - if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - if (ACE_OS::thr_getspecific (key, (void **) &ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - if (ACE_OS::thr_setspecific (key, (void *) 0) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - delete ip; - - if (ACE_OS::thr_keyfree (key) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keyfree")); - - // Cause an error. - ACE_OS::read (ACE_INVALID_HANDLE, 0, 0); - - // The following two lines set the thread-specific state. - TSS_Error->error (errno); - TSS_Error->line (__LINE__); - - // This sets the static state (note how C++ makes it easy to do - // both). - TSS_Error->flags (count); - - { - // Use the guard to serialize access to cout... - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock, 0); - - cout << "(" << ACE_Thread::self () - << ") errno = " << TSS_Error->error () - << ", lineno = " << TSS_Error->line () - << ", flags = " << TSS_Error->flags () - << endl; - } - key = 0; - - if (ACE_OS::thr_keycreate (&key, cleanup) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); - - ip = new int; - - ACE_DEBUG ((LM_DEBUG, "(%t) in worker 2, key = %d, ip = %x\n", key, ip)); - - if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - if (ACE_OS::thr_getspecific (key, (void **) &ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - if (ACE_OS::thr_setspecific (key, (void *) 0) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - delete ip; - - if (ACE_OS::thr_keyfree (key) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keyfree")); - } - - ACE_DEBUG ((LM_DEBUG, "(%t) exiting\n")); - return 0; -} - -extern "C" void -handler (int signum) -{ - ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum)); - ACE_Service_Config::thr_mgr ()->exit (0); -} - -int -main (int argc, char *argv[]) -{ - // The Service_Config must be the first object defined in main... - ACE_Service_Config daemon (argv[0]); - ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); - int threads = argc > 1 ? ACE_OS::atoi (argv[1]) : 4; - int count = argc > 2 ? ACE_OS::atoi (argv[2]) : 10000; - - // Register a signal handler. - ACE_Sig_Action sa ((ACE_SignalHandler) (handler), SIGINT); - -#if defined (ACE_HAS_THREADS) - if (ACE_Service_Config::thr_mgr ()->spawn_n (threads, - ACE_THR_FUNC (&worker), - (void *) count, - THR_BOUND | THR_DETACHED) == -1) - ACE_OS::perror ("ACE_Thread_Manager::spawn_n"); - - ACE_Service_Config::thr_mgr ()->wait (); -#else - worker ((void *) count); -#endif /* ACE_HAS_THREADS */ - return 0; -} - -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_TSS<Errno>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ - -#else -int -main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "ACE doesn't support support threads on this platform (yet)\n"), - -1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_token.cpp b/examples/Threads/test_token.cpp deleted file mode 100644 index 5a51496d011..00000000000 --- a/examples/Threads/test_token.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Test out the ACE Token class. -// $Id$ - -#include "ace/Token.h" -#include "ace/Task.h" - -#if defined (ACE_HAS_THREADS) - -class My_Task : public ACE_Task<ACE_MT_SYNCH> -{ -public: - My_Task (int n); - virtual int open (void *) { return 0; } - virtual int close (u_long) { return 0; } - virtual int put (ACE_Message_Block *, ACE_Time_Value *) { return 0; } - virtual int svc (void); - - static void sleep_hook (void *); - -private: - ACE_Token token_; -}; - -My_Task::My_Task (int n) -{ - // Make this Task into an Active Object. - this->activate (THR_BOUND | THR_DETACHED, n); - - // Wait for all the threads to exit. - this->thr_mgr ()->wait (); -} - -void -My_Task::sleep_hook (void *) -{ - cerr << '(' << ACE_Thread::self () << ')' - << " blocking, My_Task::sleep_hook () called" << endl; -} - -// Test out the behavior of the ACE_Token class. - -int -My_Task::svc (void) -{ - for (int i = 0; i < 10000; i++) - { - // Wait for up to 1 millisecond past the current time to get the token. - ACE_Time_Value timeout (ACE_OS::time (0), 1000); - - if (this->token_.acquire (&My_Task::sleep_hook, 0, &timeout) == 1) - { - this->token_.acquire (); - this->token_.renew (); - this->token_.release (); - this->token_.release (); - } - else - ACE_Thread::yield (); - } - return 0; -} - -int -main (int argc, char *argv[]) -{ - My_Task tasks (argc > 1 ? atoi (argv[1]) : 4); - - return 0; -} -#else -int -main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, "your platform doesn't support threads\n"), -1); -} -#endif /* */ diff --git a/examples/Threads/test_tss.cpp b/examples/Threads/test_tss.cpp deleted file mode 100644 index c81ca41c429..00000000000 --- a/examples/Threads/test_tss.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// Torture test ACE thread-specific storage... -// $Id$ - - -#include "ace/Task.h" -#include "ace/Token.h" - -#if defined (ACE_HAS_THREADS) - -class TSS_Obj -{ -public: - - TSS_Obj (void); - ~TSS_Obj (void); - -private: - static int count_; - static ACE_Thread_Mutex lock_; -}; - -int TSS_Obj::count_ = 0; -ACE_Thread_Mutex TSS_Obj::lock_; - -TSS_Obj::TSS_Obj (void) -{ - ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); - - count_++; - cout << "TO+ : " << count_ << endl; -} - -TSS_Obj::~TSS_Obj (void) -{ - ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); - - count_--; - cout << "TO- : " << count_ << endl; -} - -class Test_Task -{ -public: - - Test_Task (void); - ~Test_Task (void); - - int open (void *arg); - - static void* svc (void *arg); - - static int wait_count_; - static int max_count_; - -private: - static int count_; -}; - -int Test_Task::count_ = 0; -int Test_Task::wait_count_ = 0; -int Test_Task::max_count_ = 0; -int num_threads_ = 0; - -ACE_Token token; - -Test_Task::Test_Task (void) -{ - ACE_GUARD (ACE_Token, ace_mon, token); - - count_++; - cout << "Test_Task+ : " - << count_ << " (" - << ACE_OS::thr_self () - << ")" << endl; -} - -Test_Task::~Test_Task (void) -{ - ACE_GUARD (ACE_Token, ace_mon, token); - - count_--; - cout << "Test_Task- : " - << count_ << " (" - << ACE_OS::thr_self () - << ")" << endl; - - wait_count_--; -} - -int Test_Task::open (void *arg) -{ - - ACE_Thread::spawn (Test_Task::svc, arg); - - return 0; -} - - -void * -Test_Task::svc (void *arg) -{ - ACE_TSS<TSS_Obj> tss (new TSS_Obj); - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); - - wait_count_++; - max_count_++; - cout << "svc: waiting (" << ACE_OS::thr_self () << ")" << endl; - } - - while (1) - { - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); - - if (max_count_ >= num_threads_) - break; - else - { - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - } - } - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); - - cout << "svc: waiting (" << ACE_OS::thr_self () << ") finished" << endl; - } - } - - delete (Test_Task *) arg; - - return 0; -} - -int -main (int argc, char **argv) -{ - if (argc != 2) - { - cout << "Missing parameters!" << endl; - return 1; - } - - int num_Tasks = atoi (argv[1]); - - num_threads_ = num_Tasks; - - Test_Task **task_arr = (Test_Task**) new char[sizeof (Test_Task*) * num_Tasks]; - - while (1) - { - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - cout << "ReseTest_Tasking Test_Task::max_count_ from: " - << Test_Task::max_count_ << endl; - - Test_Task::max_count_ = 0; - } - - for (int i = 0; i < num_Tasks; i++) - { - task_arr[i] = new Test_Task; - task_arr[i]->open (task_arr[i]); - } - - cout << "Waiting for first thread started..." << endl; - - for (;;) - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - if (Test_Task::max_count_ != 0 ) - { - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - break; - } - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - } - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - cout << "First thread started!" << endl - << "Waiting for all threads finished..." << endl; - } - - for (;;) - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - if (!(Test_Task::max_count_ == num_threads_ - && Test_Task::wait_count_ == 0)) - { - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - continue; - } - - cout << "Test_Task::max_count_ = " - << Test_Task::max_count_ - << " Test_Task::wait_count_ = " - << Test_Task::wait_count_ - << endl; - break; - } - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - cout << "All threads finished..." << endl; - } - - ACE_OS::sleep (2); - } - - return 0; -} - -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_tss1.cpp b/examples/Threads/test_tss1.cpp deleted file mode 100644 index 7efdc9dc3ef..00000000000 --- a/examples/Threads/test_tss1.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// tests -// -// = FILENAME -// TSS_Test.cpp -// -// = DESCRIPTION -// This program tests thread specific storage of data. The ACE_TSS -// wrapper transparently ensures that the objects of this class -// will be placed in thread-specific storage. All calls on -// ACE_TSS::operator->() are delegated to the appropriate method -// in the Errno class. -// -// = AUTHOR -// Detlef Becker -// -// ============================================================================ - -#include "ace/Service_Config.h" -#include "ace/Synch.h" -#include "ace/Task.h" - -#if defined (ACE_HAS_THREADS) - -static int iterations = 100; - -class Errno -{ -public: - int error (void) { return this->errno_; } - void error (int i) { this->errno_ = i; } - - int line (void) { return this->lineno_; } - void line (int l) { this->lineno_ = l; } - - // Errno::flags_ is a static variable, so we've got to protect it - // with a mutex since it isn't kept in thread-specific storage. - int flags (void) { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_Mon, Errno::lock_, -1)); - - return Errno::flags_; - } - int flags (int f) - { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Errno::lock_, -1)); - - Errno::flags_ = f; - return 0; - } - -private: - // = errno_ and lineno_ will be thread-specific data so they don't - // need a lock. - int errno_; - int lineno_; - - static int flags_; -#if defined (ACE_HAS_THREADS) - // flags_ needs a lock. - static ACE_Thread_Mutex lock_; -#endif /* ACE_HAS_THREADS */ -}; - -// Static variables. -ACE_MT (ACE_Thread_Mutex Errno::lock_); -int Errno::flags_; - -// This is our thread-specific error handler... -static ACE_TSS<Errno> TSS_Error; - -#if defined (ACE_HAS_THREADS) -// Serializes output via cout. -static ACE_Thread_Mutex lock; - -typedef ACE_TSS_Guard<ACE_Thread_Mutex> GUARD; -#else -// Serializes output via cout. -static ACE_Null_Mutex lock; - -typedef ACE_Guard<ACE_Null_Mutex> GUARD; -#endif /* ACE_HAS_THREADS */ - -// Keeps track of whether Tester::close () has started. -static int close_started = 0; - -template <ACE_SYNCH_1> -class Tester: public ACE_Task<ACE_SYNCH_2> -{ -public: - Tester (void) {} - ~Tester (void) {} - - virtual int open (void *theArgs = 0); - virtual int close (u_long theArg = 0); - virtual int put (ACE_Message_Block *theMsgBlock, - ACE_Time_Value *theTimeVal = 0); - virtual int svc (void); -}; - -template <ACE_SYNCH_1> int -Tester<ACE_SYNCH_2>::open (void *) -{ - return this->activate (); -} - -template <ACE_SYNCH_1> -int Tester<ACE_SYNCH_2>::close (u_long) -{ - ACE_DEBUG ((LM_DEBUG, "close running\n!")); - close_started = 1; - ACE_OS::sleep (2); - ACE_DEBUG ((LM_DEBUG, "close: trying to log error code 7!\n")); - TSS_Error->error (7); - ACE_DEBUG ((LM_DEBUG, "close: logging succeeded!\n")); - return 0; -} - -template <ACE_SYNCH_1> int -Tester<ACE_SYNCH_2>::put (ACE_Message_Block *, ACE_Time_Value *) -{ - return 0; -} - -template <ACE_SYNCH_1> int -Tester<ACE_SYNCH_2>::svc (void) -{ - return 0; -} - -int -main (int, char *[]) -{ - Tester<ACE_MT_SYNCH> tester; - - tester.open (); - - while (!close_started) - continue; - - ACE_DEBUG ((LM_DEBUG, "main: trying to log error code 7!\n")); - - TSS_Error->error (3); - - ACE_DEBUG ((LM_DEBUG, "main: logging succeeded!\n")); - return 0; -} - -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_TSS<Errno>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ - -#else -int -main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "ACE doesn't support support threads on this platform (yet)\n"), - -1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Threads/test_tss2.cpp b/examples/Threads/test_tss2.cpp deleted file mode 100644 index 24a8d958e91..00000000000 --- a/examples/Threads/test_tss2.cpp +++ /dev/null @@ -1,252 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// tests -// -// = FILENAME -// TSS_Test.cpp -// -// = DESCRIPTION -// This program tests thread specific storage of data. The ACE_TSS -// wrapper transparently ensures that the objects of this class -// will be placed in thread-specific storage. All calls on -// ACE_TSS::operator->() are delegated to the appropriate method -// in the Errno class. -// -// = AUTHOR -// Prashant Jain and Doug Schmidt -// -// ============================================================================ - -#include "ace/Task.h" -#include "ace/Token.h" - -#if defined (ACE_HAS_THREADS) - -class TSS_Obj -{ -public: - - TSS_Obj (void); - ~TSS_Obj (void); - -private: - static int count_; - static ACE_Thread_Mutex lock_; -}; - -int TSS_Obj::count_ = 0; -ACE_Thread_Mutex TSS_Obj::lock_; - -TSS_Obj::TSS_Obj (void) -{ - ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); - - count_++; - cout << "TO+ : " << count_ << endl; -} - -TSS_Obj::~TSS_Obj (void) -{ - ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); - - count_--; - cout << "TO- : " << count_ << endl; -} - -class Test_Task -{ -public: - - Test_Task (void); - ~Test_Task (void); - - int open (void *arg); - - static void *svc (void *arg); - static int wait_count_; - static int max_count_; - -private: - static int count_; -}; - -int Test_Task::count_ = 0; -int Test_Task::wait_count_ = 0; -int Test_Task::max_count_ = 0; -int num_threads_ = 0; - -ACE_Token token; - -Test_Task::Test_Task (void) -{ - ACE_GUARD (ACE_Token, ace_mon, token); - - count_++; - cout << "Test_Task+ : " - << count_ << " (" - << ACE_OS::thr_self () - << ")" << endl; -} - -Test_Task::~Test_Task (void) -{ - ACE_GUARD (ACE_Token, ace_mon, token); - - count_--; - cout << "Test_Task- : " - << count_ << " (" - << ACE_OS::thr_self () - << ")" << endl; - - wait_count_--; -} - -void * -Test_Task::svc (void *arg) -{ - ACE_TSS<TSS_Obj> tss (new TSS_Obj); - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); - - wait_count_++; - max_count_++; - cout << "svc: waiting (" << ACE_OS::thr_self () << ")" << endl; - } - - while (1) - { - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); - - if (max_count_ >= num_threads_) - break; - else - { - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - } - } - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); - - cout << "svc: waiting (" << ACE_OS::thr_self () << ") finished" << endl; - } - } - - delete (Test_Task *) arg; - - return 0; -} - -int -Test_Task::open (void *arg) -{ - if (ACE_Thread::spawn (Test_Task::svc, arg) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Thread::spawn"), 0); - - return 0; -} - -int -main (int argc, char **argv) -{ - if (argc != 2) - { - cout << "Missing parameters!" << endl; - return 1; - } - - int num_Tasks = atoi (argv[1]); - - num_threads_ = num_Tasks; - - Test_Task **task_arr = (Test_Task**) new char[sizeof (Test_Task*) * num_Tasks]; - - while (1) - { - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - cout << "ReseTest_Tasking Test_Task::max_count_ from: " - << Test_Task::max_count_ << endl; - - Test_Task::max_count_ = 0; - } - - for (int i = 0; i < num_Tasks; i++) - { - task_arr[i] = new Test_Task; - task_arr[i]->open (task_arr[i]); - } - - cout << "Waiting for first thread started..." << endl; - - for (;;) - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - if (Test_Task::max_count_ != 0 ) - { - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - break; - } - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - } - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - cout << "First thread started!" << endl - << "Waiting for all threads finished..." << endl; - } - - for (;;) - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - if (!(Test_Task::max_count_ == num_threads_ - && Test_Task::wait_count_ == 0)) - { - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - continue; - } - - cout << "Test_Task::max_count_ = " - << Test_Task::max_count_ - << " Test_Task::wait_count_ = " - << Test_Task::wait_count_ - << endl; - break; - } - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - cout << "All threads finished..." << endl; - } - - ACE_OS::sleep (2); - } - - return 0; -} - -#else -int -main (int, char *[]) -{ - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); - return 0; -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp b/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp deleted file mode 100644 index bdb7047736e..00000000000 --- a/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp +++ /dev/null @@ -1,643 +0,0 @@ -//$Id: - -#ifndef CACHED_CONNECT_STRATEGY_T_C -#define CACHED_CONNECT_STRATEGY_T_C - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/ACE.h" -#include "Cached_Connect_Strategy_T.h" -#include "ace/Service_Repository.h" -#include "ace/Synch.h" -#include "ace/Service_Types.h" -#include "ace/Thread_Manager.h" -#include "ace/WFMO_Reactor.h" -#include "ace/Pair_T.h" -#include "Options.h" - -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "Cached_Connect_Strategy_T.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - -ACE_RCSID(Web_Crawler, Cached_Connect_Strategy_T, "$Id$") - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::ACE_Cached_Connect_Strategy_Ex - (ACE_Creation_Strategy<SVC_HANDLER> *cre_s, - ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, - ACE_Recycling_Strategy<SVC_HANDLER> *rec_s) - : creation_strategy_ (0), - delete_creation_strategy_ (0), - concurrency_strategy_ (0), - delete_concurrency_strategy_ (0), - recycling_strategy_ (0), - delete_recycling_strategy_ (0) -{ - - ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::ACE_Cached_Connect_Strategy_Ex\n")); - - if (this->open (cre_s, con_s, rec_s) == -1) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("%p\n"), - ASYS_TEXT ("ACE_Cached_Connect_Strategy_Ex::ACE_Cached_Connect_Strategy_Ex"))); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::~ACE_Cached_Connect_Strategy_Ex (void) -{ - ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::~ACE_Cached_Connect_Strategy_Ex\n")); - if (this->delete_creation_strategy_) - delete this->creation_strategy_; - this->delete_creation_strategy_ = 0; - this->creation_strategy_ = 0; - - if (this->delete_concurrency_strategy_) - delete this->concurrency_strategy_; - this->delete_concurrency_strategy_ = 0; - this->concurrency_strategy_ = 0; - - if (this->delete_recycling_strategy_) - delete this->recycling_strategy_; - this->delete_recycling_strategy_ = 0; - this->recycling_strategy_ = 0; - - // Close down all cached service handlers. - for (CONNECTION_CACHE_ITERATOR iter = this->connection_cache_.begin (); - iter != this->connection_cache_.end (); - ++iter) - { - if ((*iter).second () != 0) - { - (*iter).second ()->recycler (0, 0); - (*iter).second ()->close (); - } - } -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::open - (ACE_Creation_Strategy<SVC_HANDLER> *cre_s, - ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, - ACE_Recycling_Strategy<SVC_HANDLER> *rec_s) -{ - // Initialize the creation strategy. - // First we decide if we need to clean up. - if (this->creation_strategy_ != 0 && - this->delete_creation_strategy_ != 0 && - cre_s != 0) - { - delete this->creation_strategy_; - this->creation_strategy_ = 0; - this->delete_creation_strategy_ = 0; - } - - if (cre_s != 0) - this->creation_strategy_ = cre_s; - else if (this->creation_strategy_ == 0) - { - ACE_NEW_RETURN (this->creation_strategy_, - CREATION_STRATEGY, -1); - this->delete_creation_strategy_ = 1; - } - - // Initialize the concurrency strategy. - - if (this->concurrency_strategy_ != 0 && - this->delete_concurrency_strategy_ != 0 && - con_s != 0) - { - delete this->concurrency_strategy_; - this->concurrency_strategy_ = 0; - this->delete_concurrency_strategy_ = 0; - } - - if (con_s != 0) - this->concurrency_strategy_ = con_s; - else if (this->concurrency_strategy_ == 0) - { - ACE_NEW_RETURN (this->concurrency_strategy_, - CONCURRENCY_STRATEGY, -1); - this->delete_concurrency_strategy_ = 1; - } - - // Initialize the recycling strategy. - - if (this->recycling_strategy_ != 0 && - this->delete_recycling_strategy_ != 0 && - rec_s != 0) - { - delete this->recycling_strategy_; - this->recycling_strategy_ = 0; - this->delete_recycling_strategy_ = 0; - } - - if (rec_s != 0) - this->recycling_strategy_ = rec_s; - else if (this->recycling_strategy_ == 0) - { - ACE_NEW_RETURN (this->recycling_strategy_, - RECYCLING_STRATEGY, -1); - this->delete_recycling_strategy_ = 1; - } - - return 0; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::check_hint_i - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry, - int &found) -{ - ACE_UNUSED_ARG (remote_addr); - ACE_UNUSED_ARG (timeout); - ACE_UNUSED_ARG (local_addr); - ACE_UNUSED_ARG (reuse_addr); - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (perms); - - found = 0; - - // Get the recycling act for the svc_handler - CONNECTION_CACHE_ENTRY *possible_entry = (CONNECTION_CACHE_ENTRY *) sh->recycling_act (); - - // Check to see if the hint svc_handler has been closed down - if (possible_entry->ext_id_.state () == ACE_Recyclable::CLOSED) - { - // If close, decrement refcount - if (possible_entry->ext_id_.decrement () == 0) - { - // If refcount goes to zero, close down the svc_handler - possible_entry->int_id_.first ()->recycler (0, 0); - possible_entry->int_id_.first ()->close (); - this->purge_i (possible_entry); - } - - // Hint not successful - found = 0; - - // Reset hint - sh = 0; - } - - // If hint is not closed, see if it is connected to the correct - // address and is recyclable - else if (possible_entry->ext_id_ == remote_addr) - { - // Hint successful - found = 1; - - // Tell the <svc_handler> that it should prepare itself for - // being recycled. - this->prepare_for_recycling (sh); - } - else - { - // This hint will not be used. - possible_entry->ext_id_.decrement (); - - // Hint not successful - found = 0; - - // If <sh> is not connected to the correct address or is busy, - // we will not use it. - sh = 0; - } - - if (found) - entry = possible_entry; - - return 0; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::find_or_create_svc_handler_i - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry, - int &found) -{ - - ACE::set_handle_limit (OPTIONS::instance ()->handle_limit ()); - //ACE_DEBUG ((LM_DEBUG, "MAX handles %d \n", ACE::max_handles ())); - // Explicit type conversion - REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr); - - // Try to find the address in the cache. Only if we don't find it - // do we create a new <SVC_HANDLER> and connect it with the server. - if (this->connection_cache_.find (search_addr, entry) == -1) - { - // Set the flag - found = 0; - - // Create a new svc_handler - if (this->make_svc_handler (sh) == -1) - return -1; - - if (this->connect (...) == -1) - { - return -1; - } - else - { - // Insert the new SVC_HANDLER instance into the cache. - if (this->connection_cache_.bind (search_addr, - sh, - entry) == -1) - return -1; - - // Set the recycler and the recycling act - this->assign_recycler (sh, this, entry); - } - } - else // We found a cached svc_handler. - { - // Set the flag - found = 1; - - // Get the cached <svc_handler> - sh = entry->int_id_.first (); - - // Tell the <svc_handler> that it should prepare itself for - // being recycled. - this->prepare_for_recycling (sh); - } - - return 0; - -} - -connect () -{ - // Actively establish the connection. This is a timed blocking - // connect. - if (this->CONNECT_STRATEGY::connect_svc_handler (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms) == -1) - { - // If connect() failed because of timeouts, we have to reject - // the connection entirely. This is necessary since currently - // there is no way for the non-blocking connects to complete and - // for the <Connector> to notify the cache of the completion of - // connect(). - if (errno == EWOULDBLOCK) - errno = ENOTSUP; - else if (errno == EMFILE) - { - // @@purge here... - - // Try connecting again. - if (this->CONNECT_STRATEGY::connect_svc_handler (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms) == -1) - { - if (errno == EWOULDBLOCK) - errno = ENOTSUP; - return -1; - } - } - else - { - return -1; - } - } - else - { - return 0; - } -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::connect_svc_handler - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - - ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::connect_svc_handler\n")); - int found = 0; - - // This artificial scope is required since we need to let go of the - // lock *before* registering the newly created handler with the - // Reactor. - { - // Synchronization is required here as the setting of the - // recyclable state must be done atomically with the finding and - // binding of the service handler in the cache. - ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1); - - int result = this->connect_svc_handler_i (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms, - found); - if (result != 0) - return result; - - } - - // If it is a new connection, activate it. - // - // Note: This activation is outside the scope of the lock of the - // cached connector. This is necessary to avoid subtle deadlock - // conditions with this lock and the Reactor lock. - // - // @@ If an error occurs on activation, we should try to remove this - // entry from the internal table. - - if (!found) - if (this->activate_svc_handler (sh)) - return -1; - - return 0; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::connect_svc_handler - (SVC_HANDLER *&sh, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) -{ - int found = 0; - - // This artificial scope is required since we need to let go of the - // lock *before* registering the newly created handler with the - // Reactor. - { - // Synchronization is required here as the setting of the - // recyclable state must be done atomically with the finding and - // binding of the service handler in the cache. - ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1); - - int result = this->connect_svc_handler_i (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms, - found); - sh_copy = sh; - - ACE_DEBUG ((LM_DEBUG,"after connect_svc_handler_i ACE_Cached_Connect_Strategy_Ex::connect_svc_handler sh_Copy result =%d\n", result)); - if (result != 0) - return result; - - } - - // If it is a new connection, activate it. - // - // Note: This activation is outside the scope of the lock of the - // cached connector. This is necessary to avoid subtle deadlock - // conditions with this lock and the Reactor lock. - // - // @@ If an error occurs on activation, we should try to remove this - // entry from the internal table. - - if (!found) - if (this->activate_svc_handler (sh)) - return -1; - - return 0; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::connect_svc_handler_i - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - int& found) -{ - CONNECTION_CACHE_ENTRY *entry = 0; - - // Check if the user passed a hint svc_handler - if (sh != 0) - { - - int result = this->check_hint_i (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms, - entry, - found); - // @@ Remove debugging - ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::connect_svc_handler_i CHECK_HINT_I result = %d\n", result)); - - if (result != 0) - return result; - } - - // If not found - if (!found) - { - int result = this->find_or_create_svc_handler_i (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms, - entry, - found); - - // @@ Purging here is not correct... - - if (result != 0) - { - // If the connect failed due to the process running out of - // file descriptors then, auto_purging of some connections - // are done from the CONNECTION_CACHE. This frees the - // descriptors which get used in the connect process and - // hence the same method is called again! - if (errno == EMFILE) - { - int result = this->connection_cache_.purge (); - if (result == -1) - return result; - - if (this->find_or_create_svc_handler_i (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms, - entry, - found) == -1) - return -1; - } - else - return result; - } - } - - // For all successful cases: mark the <svc_handler> in the cache - // as being <in_use>. Therefore recyclable is BUSY. - entry->ext_id_.state (ACE_Recyclable::BUSY); - - // And increment the refcount - entry->ext_id_.increment (); - - return 0; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::cache (const void *recycling_act) -{ - // Synchronization is required here as the setting of the recyclable - // state must be done atomically with respect to other threads that - // are querying the cache. - ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1); - - ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::cache\n")); - return this->cache_i (recycling_act); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::cache_i (const void *recycling_act) -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - // Mark the <svc_handler> in the cache as not being <in_use>. - // Therefore recyclable is IDLE. - - entry->ext_id_.state (ACE_Recyclable::IDLE); - - return 0; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::purge (const void *recycling_act) -{ - // Excluded other threads from changing cache while we take this - // entry out. - ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1); - - return this->purge_i (recycling_act); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::purge_i (const void *recycling_act) -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - return this->connection_cache_.unbind (entry); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::mark_as_closed (const void *recycling_act) -{ - // Excluded other threads from changing cache while we take this - // entry out. - ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1); - - return this->mark_as_closed_i (recycling_act); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::mark_as_closed_i (const void *recycling_act) -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - // Mark the <svc_handler> in the cache as CLOSED. - entry->ext_id_.state (ACE_Recyclable::CLOSED); - - return 0; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::cleanup_hint (const void *recycling_act) -{ - // Excluded other threads from changing cache while we take this - // entry out. - ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1); - - return this->cleanup_hint_i (recycling_act); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::cleanup_hint_i (const void *recycling_act) -{ - // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - - // Decrement the refcount on the <svc_handler>. - int refcount = entry->ext_id_.decrement (); - - // If the svc_handler state is closed and the refcount == 0, call - // close() on svc_handler. - if (entry->ext_id_.state () == ACE_Recyclable::CLOSED && - refcount == 0) - { - entry->int_id_.first ()->recycler (0, 0); - entry->int_id_.first ()->close (); - this->purge_i (entry); - } - - return 0; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_Creation_Strategy<SVC_HANDLER> * -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::creation_strategy (void) const -{ - return this->creation_strategy_; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_Recycling_Strategy<SVC_HANDLER> * -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::recycling_strategy (void) const -{ - return this->recycling_strategy_; -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_Concurrency_Strategy<SVC_HANDLER> * -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::concurrency_strategy (void) const -{ - return this->concurrency_strategy_; -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Cached_Connect_Strategy_Ex) - -#endif /* CACHED_CONNECT_STRATEGY_T_C */ diff --git a/examples/Web_Crawler/Cached_Connect_Strategy_T.h b/examples/Web_Crawler/Cached_Connect_Strategy_T.h deleted file mode 100644 index 2f81d41a33b..00000000000 --- a/examples/Web_Crawler/Cached_Connect_Strategy_T.h +++ /dev/null @@ -1,249 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// Cached_Connect_Strategy_T.h -// -// = AUTHOR -// Kirthika Parameswaran -// -// ============================================================================ - -#ifndef CACHED_CONNECT_STRATEGY_T_H -#define CACHED_CONNECT_STRATEGY_T_H - -#include "ace/Strategies_T.h" -#include "ace/Hash_Map_Manager_T.h" -#include "Optimal_Cache_Map_Manager_T.h" -#include "Caching_Strategies_T.h" -#include "ace/Functor_T.h" -#include "ace/Pair_T.h" -#include "ace/Synch.h" - -template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> -class ACE_Cached_Connect_Strategy_Ex : public ACE_Connection_Recycling_Strategy, public ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> -{ - // = TITLE - // A connection strategy which caches connections to peers - // (represented by <SVC_HANDLER> instances), thereby allowing - // subsequent re-use of unused, but available, connections. - // - // = DESCRIPTION - // <Mem_Cached_Connect_Strategy> is intended to be used as a - // plug-in connection strategy for <ACE_Strategy_Connector>. - // It's added value is re-use of established connections. - // - // = USAGE - // In order to use this appropriately, the user must provide - // a template specialization for <ACE_Hash_Addr::compare_i()> and - // <ACE_Hash_Addr::hash_i()> based on the address type and the - // service handler type. For example, a specialization using - // <ACE_INET_Addr> and <My_Service_Handler> might be: - // = BEGIN<NOFILL> - // = BEGIN<CODE> - // size_t - // ACE_Hash_Addr<ACE_INET_Addr, My_Service_Handler>::hash_i(const ACE_INET_Addr &a) - // { - // return ...; - // } - // = END<CODE> - // = END<NOFILL> - // - // = SEE ALSO - // <ACE_Hash_Addr>. -public: - - ACE_Cached_Connect_Strategy_Ex (ACE_Creation_Strategy<SVC_HANDLER> *cre_s = 0, - ACE_Concurrency_Strategy<SVC_HANDLER> *con_s = 0, - ACE_Recycling_Strategy<SVC_HANDLER> *rec_s = 0); - // Constructor - - virtual ~ACE_Cached_Connect_Strategy_Ex (void); - // Destructor - - virtual int open (ACE_Creation_Strategy<SVC_HANDLER> *cre_s, - ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, - ACE_Recycling_Strategy<SVC_HANDLER> *rec_s); - // This methods allow you to change the strategies used by the - // cached connector. - - virtual int make_svc_handler (SVC_HANDLER *&sh); - // Template method for making a new <svc_handler> - - virtual int activate_svc_handler (SVC_HANDLER *svc_handler); - // Template method for activating a new <svc_handler> - - virtual int assign_recycler (SVC_HANDLER *svc_handler, - ACE_Connection_Recycling_Strategy *recycler, - const void *recycling_act); - // Template method for setting the recycler information of the - // svc_handler. - - virtual int prepare_for_recycling (SVC_HANDLER *svc_handler); - // Template method for preparing the svc_handler for recycling. - - virtual int connect_svc_handler (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms); - - virtual int connect_svc_handler (SVC_HANDLER *&sh, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms); - // Checks to see if there is already a <SVC_HANDLER> in the cache - // connected to the <remote_addr>. If so, we return this pointer. - // Otherwise we establish the connection, put it into the cache, and - // return the <SVC_HANDLER> pointer. <[NOTE]>: the <{reuse_addr}> - // argument does NOT control re-use of addresses in the cache. - // Rather, if the underlying protocol requires a "dead time" prior - // to re-use of its addresses (TCP is a classic example of this), - // <{and}> the protocol provides a means by which to defeat the dead - // time, setting this argument to non-zero will defeat the dead-time - // requirement. <{Dev. Note: We might want to consider enhancing - // the interface at some point so that this also controls re-use of - // the cache.}> - - virtual int purge (const void *recycling_act); - // Remove from cache. - - virtual int cache (const void *recycling_act); - // Add to cache. - - virtual int mark_as_closed (const void *recycling_act); - // Mark as closed. - - virtual int cleanup_hint (const void *recycling_act); - // Cleanup hint. - - // = Define some useful typedefs. - typedef ACE_Creation_Strategy<SVC_HANDLER> - CREATION_STRATEGY; - typedef ACE_Concurrency_Strategy<SVC_HANDLER> - CONCURRENCY_STRATEGY; - typedef ACE_Recycling_Strategy<SVC_HANDLER> - RECYCLING_STRATEGY; - - // = Super class - typedef ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> - CONNECT_STRATEGY; - - // = Typedefs for managing the map - typedef ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR> - REFCOUNTED_HASH_RECYCLABLE_ADDRESS; - - typedef ACE_Optimal_Cache_Map_Manager<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, CACHING_STRATEGY> - CONNECTION_CACHE; - typedef ACE_Optimal_Cache_Map_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, CACHING_STRATEGY> - CONNECTION_CACHE_ITERATOR; - typedef ACE_Optimal_Cache_Map_Reverse_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, CACHING_STRATEGY> - CONNECTION_CACHE_REVERSE_ITERATOR; - - typedef ACE_TYPENAME CONNECTION_CACHE::CACHE_ENTRY - CONNECTION_CACHE_ENTRY; - // = Strategy accessors - virtual ACE_Creation_Strategy<SVC_HANDLER> *creation_strategy (void) const; - virtual ACE_Recycling_Strategy<SVC_HANDLER> *recycling_strategy (void) const; - virtual ACE_Concurrency_Strategy<SVC_HANDLER> *concurrency_strategy (void) const; - -protected: - - virtual int purge_i (const void *recycling_act); - // Remove from cache (non-locking version). - - virtual int cache_i (const void *recycling_act); - // Add to cache (non-locking version). - - virtual int mark_as_closed_i (const void *recycling_act); - // Mark as closed (non-locking version). - - virtual int cleanup_hint_i (const void *recycling_act); - // Cleanup hint. - - // = Helpers - int check_hint_i (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry, - int &found); - - int connect_svc_handler_i (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - int &found); - - int find_or_create_svc_handler_i (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry, - int &found); - - CONNECTION_CACHE connection_cache_; - // Table that maintains the cache of connected <SVC_HANDLER>s. - - MUTEX lock_; - // Mutual exclusion for this object. - - // = Strategy objects. - - CREATION_STRATEGY *creation_strategy_; - // Creation strategy for an <Connector>. - - int delete_creation_strategy_; - // 1 if <Connector> created the creation strategy and thus should - // delete it, else 0. - - CONCURRENCY_STRATEGY *concurrency_strategy_; - // Concurrency strategy for an <Connector>. - - int delete_concurrency_strategy_; - // 1 if <Connector> created the concurrency strategy and thus should - // delete it, else 0. - - RECYCLING_STRATEGY *recycling_strategy_; - // Recycling strategy for an <Connector>. - - int delete_recycling_strategy_; - // 1 if <Connector> created the recycling strategy and thus should - // delete it, else 0. -}; - - - -#if !defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "Cached_Connect_Strategy_T.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "Cached_Connect_Strategy_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Cached_Connect_Strategy_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#endif /* CACHED_CONNECT_STRATEGY_T_H */ diff --git a/examples/Web_Crawler/Cached_Connect_Strategy_T.i b/examples/Web_Crawler/Cached_Connect_Strategy_T.i deleted file mode 100644 index 59fa304deeb..00000000000 --- a/examples/Web_Crawler/Cached_Connect_Strategy_T.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- C++ -*- */ -//$Id$ - - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_INLINE int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::make_svc_handler - (SVC_HANDLER *&sh) -{ - return this->creation_strategy_->make_svc_handler (sh); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_INLINE int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::activate_svc_handler - (SVC_HANDLER *svc_handler) -{ - return this->concurrency_strategy_->activate_svc_handler (svc_handler); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_INLINE int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::assign_recycler - (SVC_HANDLER *svc_handler, - ACE_Connection_Recycling_Strategy *recycler, - const void *recycling_act) -{ - return this->recycling_strategy_->assign_recycler (svc_handler, - recycler, - recycling_act); -} - -template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_INLINE int -ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::prepare_for_recycling - (SVC_HANDLER *svc_handler) -{ - return this->recycling_strategy_->prepare_for_recycling (svc_handler); -} diff --git a/examples/Web_Crawler/Caching_Strategies_T.cpp b/examples/Web_Crawler/Caching_Strategies_T.cpp deleted file mode 100644 index 8bb86f1f730..00000000000 --- a/examples/Web_Crawler/Caching_Strategies_T.cpp +++ /dev/null @@ -1,259 +0,0 @@ -//$Id$ - -#ifndef CACHING_STRATEGIES_T_C -#define CACHING_STRATEGIES_T_C - -#include "Caching_Strategies_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (__ACE_INLINE__) -#include "Caching_Strategies_T.i" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(Web_Crawler, Caching_Strategies_T, "$Id$") - -template<class CONTAINER> int -ACE_LRU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) -{ - // Check that the purge_percent is non-zero. - if (this->purge_percent_ == 0) - return 0; - - // Also whether the number of entries in the cache is just one! - // Oops! then thers no way out but exiting. So return an error. - if (this->entries_ == 1) - return -1; - - KEY key_to_remove; - VALUE value_to_remove; - - ITEM *item = 0; - - ATTRIBUTES min = 0; - - // Return value. - int result = 0; - - // Calculate the no of entries to remove form the cache depending - // upon the <purge_percent>. - int no_of_entries = (this->purge_percent_ / 100) * this->entries_; - - // @@ Don't do this stuff below. Simply take the ceiling of the - // above <no_of_entries>. - - // If the number of entries is less than 10 with the default percent - // being 10, the calculated no_pf_entries equals 0. So increment it - // so that atleast one entry gets purged. - if (no_of_entries == 0) - { - if (container.current_size () >= 1) - no_of_entries = 1; - } - - for (int i = 0; i < no_of_entries ; ++i) - { - ITERATOR iter (container); - - // The iterator moves thru the container searching for the entry with the - // lowest ATTRIBUTES. - - for (min = (*iter).int_id_.second (), key_to_remove = (*iter).ext_id_, value_to_remove = (*iter).int_id_; - iter.next (item) != 0; - ++iter) - { - // Ah! an item with lower ATTTRIBUTES... - if (min > (*iter).int_id_.second ()) - { - min = (*iter).int_id_.second (); - key_to_remove = (*iter).ext_id_; - value_to_remove = (*iter).int_id_; - } - } - - // @@ Remove this - ACE_DEBUG ((LM_DEBUG, "AUTO_PURGE\nLRU: before unbind: current_size %d\n", container.current_size ())); - - // @@ Remove this svc_handler specific code!! - - // Delete the dynamically allocated value object. - if (value_to_remove.first () != 0) - { - (value_to_remove.first ())->recycler (0, 0); - - result = (value_to_remove.first ())->close(); - if (result == -1) - return result; - } - // Remove the item from cache. - - // @@ What happens to this result? You should stop on failure. - result = container.unbind (key_to_remove); - --this->entries_; - - // @@ Remove this - ACE_DEBUG ((LM_DEBUG, "LRU:after unbind: result %d current_size %d\n", result, container.current_size ())); - } - return result; -} - -//////////////////////////////////////////////////////////////////////////////////////////////// -template<class CONTAINER> int -ACE_LFU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) -{ - // Check that the purge_percent is non-zero. - if (purge_percent_ == 0) - return 0; - - // Also whether the number of entries in the cache is just one! - // Oops! then thers no way out but exiting. So return an error. - if (this->entries_ == 1) - return -1; - - KEY key_to_remove; - VALUE value_to_remove; - - ITEM *item = 0; - - ATTRIBUTES min = 0; - - // Return value. - int result = 0; - - // Calculate the no of entries to remove form the cache depending upon the <purge_percent>. - int no_of_entries = (this->purge_percent_/100) * this->entries_; - // If the number of entries is less than 10 with the default percent - // being 10, the calculated no_pf_entries equals 0. So increment it - // so that atleast one entry gets purged. - if (no_of_entries == 0) - { - if (container.current_size () >= 1) - no_of_entries = 1; - } - - for (int i = 0; i < no_of_entries ; ++i) - { - ITERATOR iter (container); - // The iterator moves thru the container searching for the entry with the - // lowest ATTRIBUTES. - - for (min = (*iter).int_id_.second (), key_to_remove = (*iter).ext_id_, value_to_remove = (*iter).int_id_; - iter.next (item) != 0 ; - ++iter) - { - // Ah! an item with lower ATTTRIBUTES... - if (min > (*iter).int_id_.second ()) - { - min = (*iter).int_id_.second (); - key_to_remove = (*iter).ext_id_; - value_to_remove = (*iter).int_id_; - } - } - ACE_DEBUG ((LM_DEBUG, "AUTO_PURGE\nLFU: before unbind: current_size %d\n", container.current_size ())); - - // Delete the dynamically allocated value object. - if (value_to_remove.first () != 0) - { - (value_to_remove.first ())->recycler (0, 0); - - result = (value_to_remove.first ())->close(); - if (result == -1) - return result; - } - // Remove the item from cache. - result = container.unbind (key_to_remove); - --this->entries_; - ACE_DEBUG ((LM_DEBUG, "LFU:after unbind: result %d current_size %d\n", result, container.current_size ())); - } - return result; - -} - -//////////////////////////////////////////////////////////////////////////////////////////////// -template<class CONTAINER> int -ACE_FIFO_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) -{ - // Check that the purge_percent is non-zero. - if (this->purge_percent_ == 0) - return 0; - - // Also whether the number of entries in the cache is just one! - // Oops! then thers no way out but exiting. So return an error. - if (this->entries_ == 1) - return -1; - - KEY key_to_remove; - VALUE value_to_remove; - - ITEM *item = 0; - - ATTRIBUTES min = 0; - - // Return value. - int result = 0; - - // Calculate the no of entries to remove form the cache depending upon the <purge_percent>. - int no_of_entries = (this->purge_percent_/100) * this->entries_; - // If the number of entries is less than 10 with the default percent - // being 10, the calculated no_pf_entries equals 0. So increment it - // so that atleast one entry gets purged. - if (no_of_entries == 0) - { - if (container.current_size () >= 1) - no_of_entries = 1; - } - - for (int i = 0; i < no_of_entries ; ++i) - { - ITERATOR iter (container); - // The iterator moves thru the container searching for the entry with the - // lowest ATTRIBUTES. - for (min = (*iter).int_id_.second (), key_to_remove = (*iter).ext_id_, value_to_remove = (*iter).int_id_; - iter.next (item) != 0 ; - ++iter) - { - // Ah! an item with lower ATTTRIBUTES... - if (min > (*iter).int_id_.second ()) - { - min = (*iter).int_id_.second (); - key_to_remove = (*iter).ext_id_; - value_to_remove = (*iter).int_id_; - } - } - ACE_DEBUG ((LM_DEBUG, "AUTO_PURGE\nFIFO: before unbind: current_size %d\n", container.current_size ())); - - // Delete the dynamically allocated value object. - if (value_to_remove.first () != 0) - { - (value_to_remove.first ())->recycler (0, 0); - - result = (value_to_remove.first ())->close(); - if (result == -1) - return result; - } - // Remove the item from cache. - result = container.unbind (key_to_remove); - --this->entries_; - ACE_DEBUG ((LM_DEBUG, "FIFO:after unbind: result %d current_size %d\n", result, container.current_size ())); - } - return result; - -} - -//////////////////////////////////////////////////////////////////////////////////////////////// - -template<class CONTAINER> int -ACE_Null_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) -{ - return 0; -} - -/////////////////////////////////////////////////////////////////////////////////////////////// - -ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE(ACE_LFU_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE(ACE_Null_Caching_Strategy) -#endif /* CACHING_STRATEGIES_T_C */ diff --git a/examples/Web_Crawler/Caching_Strategies_T.h b/examples/Web_Crawler/Caching_Strategies_T.h deleted file mode 100644 index f62aee5da02..00000000000 --- a/examples/Web_Crawler/Caching_Strategies_T.h +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// Caching_Strategies_T.h -// -// = AUTHOR -// Kirthika Parameswaran <kirthika@cs.wustl.edu> -// -// ============================================================================ - -#ifndef CACHING_STRATEGIES_H -#define CACHING_STRATEGIES_H - -#include "ace/OS.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -template <class CONTAINER> -class ACE_LRU_Caching_Strategy -{ - // = TITLE - // Defines a Least Recently Used strategy which will decide on - // the item to be removed from the cache. - // - // = DESCRIPTION - // This is a strategy which makes use of a virtual timer which - // is updated whenever an item is inserted or looked up in the - // container. When the need of purging entries arises, the items - // with the lowest timer values are removed. - -public: - - // Traits. - typedef int ATTRIBUTES; - - // @@ Should these be here? - typedef ACE_TYPENAME CONTAINER::KEY KEY; - typedef ACE_TYPENAME CONTAINER::VALUE VALUE; - typedef ACE_TYPENAME CONTAINER::ITERATOR ITERATOR; - typedef ACE_TYPENAME CONTAINER::ENTRY ITEM; - - // = Initialisation and termination. - - ACE_LRU_Caching_Strategy (CONTAINER &container, - ATTRIBUTES timer = 0, - int purge_percent = 10); - // The <container> is the map in which the entries reside. - // The timer attribute could be initialsed as per need. - // The <purge_percent> field denotes the percentage of the entries - // in the cache which can be purged automagically. - - ~ACE_LRU_Caching_Strategy (void); - - // = Operations of the startegy. - - ATTRIBUTES attributes (void); - // Accessor method for the timer attributes. - - // = Accessor methods for the percentage of entries to purge. - int purge_percent (void); - void purge_percent (int percentage); - - // = Strategy related Operations - - int notify_bind (int result, - const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs bind - // method call. - - int notify_find (int result, - ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs find - // method call - - int notify_unbind (int result, - const ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs unbind - // method call - - int notify_trybind (int result, - ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs trybind - // method call - - int notify_rebind (int result, - const ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs rebind - // method call - - int clear_cache (CONTAINER &container); - // This is the method which looks at each ITEM's attributes and - // then decides on the one to remove. - - void dump (void) const; - // Dumps the state of the object. - - private: - - ATTRIBUTES timer_; - // This element is the one which is the deciding factor for purging - // of an ITEM. - - CONTAINER &container_; - // The container over which the purging will occur according to the - // strategy. - - int purge_percent_; - // The level about which the purging will happen automagically. - - int entries_; - // The no of entries bound in the cache. -}; - -////////////////////////////////////////////////////////////////////////// - -template <class CONTAINER> -class ACE_LFU_Caching_Strategy -{ - // = TITLE - // Defines a Least Frequently Used strategy for which will decide on - // the item to be removed from the cache. - // - // = DESCRIPTION - // A attribute is tagged to each item which increments whenever - // the item is bound or looked up in the cache. Thus it denotes - // the frequency of use. According to the value of the attribute - // the item is removed from the CONTAINER i.e cache. -public: - - // Traits. - typedef int ATTRIBUTES; - - typedef ACE_TYPENAME CONTAINER::KEY KEY; - - typedef ACE_TYPENAME CONTAINER::VALUE VALUE; - - typedef ACE_TYPENAME CONTAINER::ITERATOR ITERATOR; - - typedef ACE_TYPENAME CONTAINER::ENTRY ITEM; - - // = Initialisation and termination methods. - - ACE_LFU_Caching_Strategy (void); - - ~ACE_LFU_Caching_Strategy (void); - - // = Startegy methods. Most of the methods are used from the base - // class itself. - - ATTRIBUTES attributes (void); - // Access the attributes. - - int notify_bind (int result, - const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs bind - // method call. - - int notify_find (int result, - ATTRIBUTES &attr); - // Lookup notification. - - int notify_unbind (int result, - const ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs unbind - // method call - - int notify_trybind (int result, - ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs trybind - // method call - - int notify_rebind (int result, - const ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs rebind - // method call - - int clear_cache (CONTAINER &container); - // This is the method which looks at each ITEM's attributes and - // then decides on the one to remove. - - void dump (void) const; - // Dumps the state of the object. -}; - -///////////////////////////////////////////////////////////// - -template<class CONTAINER> -class ACE_FIFO_Caching_Strategy -{ - // = TITLE - // The First In First Out startegy is implemented wherein each - // item is ordered. - // - // = DESCRIPTION - // The order tag of each item is used to decide the item to be - // removed from the cache. The items with least order are removed. - public: - - typedef int ATTRIBUTES; - - // Traits. - typedef ACE_TYPENAME CONTAINER::KEY KEY; - - typedef ACE_TYPENAME CONTAINER::VALUE VALUE; - - typedef ACE_TYPENAME CONTAINER::ITERATOR ITERATOR; - - typedef ACE_TYPENAME CONTAINER::ENTRY ITEM; - - // = Initialisation and termination. - - ACE_FIFO_Caching_Strategy (ATTRIBUTES order = 0); - - ~ACE_FIFO_Caching_Strategy (void); - - // = Startegy methods. - - ATTRIBUTES attributes (void); - // Accessor method. - - int notify_bind (int result, - const ATTRIBUTES &attr); - // Notification for an item getting bound into the cache. - - int notify_find (int result, - ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs find - // method call - - int notify_unbind (int result, - const ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs unbind - // method call - - int notify_trybind (int result, - ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs trybind - // method call - - int notify_rebind (int result, - const ATTRIBUTES &attr); - // Notification for an item getting bound again into the cache. - - int clear_cache (CONTAINER &container); - // This is the method which looks at each ITEM's attributes and - // then decides on the one to remove. - - void dump (void) const; - // Dumps the state of the object. -private: - - ATTRIBUTES order_; - // The order is the deciding factor for the item to be removed from - // the cache. -}; - -template<class CONTAINER> -class ACE_Null_Caching_Strategy -{ - // = TITLE - // The is a special caching strategy which doesnt have the purging - // feature. - // - // = DESCRIPTION - // No purging provided. To be used when purging might be too expensive - // an operation. - - public: - - typedef int ATTRIBUTES; - - // = Initialisation and termination. - - ACE_Null_Caching_Strategy (void); - - ~ACE_Null_Caching_Strategy (void); - - // = Startegy methods. All are NO_OP methods!!! - - ATTRIBUTES attributes (void); - // Accessor method. - - int notify_bind (int result, - const ATTRIBUTES &attr); - // Notification for an item getting bound into the cache. - - int notify_find (int result, - ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs find - // method call - - int notify_unbind (int result, - const ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs unbind - // method call - - int notify_trybind (int result, - ATTRIBUTES &attr); - //This method acts as a notification about the CONTAINERs trybind - // method call - - int notify_rebind (int result, - const ATTRIBUTES &attr); - // Notification for an item getting bound again into the cache. - - int clear_cache (CONTAINER &container); - // This is the method which looks at each ITEM's attributes and - // then decides on the one to remove. - - void dump (void) const; - // Dumps the state of the object. - -private: - - // @@ Remove this - ATTRIBUTES dummy_; - // Just a dummy member to be able to keep up with the common interface. -}; - -#if defined (__ACE_INLINE__) -#include "Caching_Strategies_T.i" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "Caching_Strategies_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation "Caching_Strategies_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#endif /* CACHING_STRATEGIES_H */ diff --git a/examples/Web_Crawler/Caching_Strategies_T.i b/examples/Web_Crawler/Caching_Strategies_T.i deleted file mode 100644 index 4465a7ebff6..00000000000 --- a/examples/Web_Crawler/Caching_Strategies_T.i +++ /dev/null @@ -1,287 +0,0 @@ -/* -*-C++-*- */ -//$Id$ - -template<class CONTAINER> ACE_INLINE -ACE_LRU_Caching_Strategy<CONTAINER>::ACE_LRU_Caching_Strategy (CONTAINER &container, ATTRIBUTES timer, int purge_percent) - : timer_ (timer), - container_ (container), - purge_percent_ (purge_percent), - entries_ (0) -{ -} - -template<class CONTAINER> ACE_INLINE -ACE_LRU_Caching_Strategy<CONTAINER>::~ACE_LRU_Caching_Strategy (void) -{ -} - -template<class CONTAINER> ACE_INLINE ACE_LRU_Caching_Strategy<CONTAINER>::ATTRIBUTES -ACE_LRU_Caching_Strategy<CONTAINER>::attributes (void) -{ - return this->timer_; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LRU_Caching_Strategy<CONTAINER>::purge_percent (void) -{ - return this->purge_percent_; -} - -template<class CONTAINER> ACE_INLINE void -ACE_LRU_Caching_Strategy<CONTAINER>::purge_percent (int percentage) -{ - this->purge_percent_ = percentage; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LRU_Caching_Strategy<CONTAINER>::notify_bind (int result, - const ATTRIBUTES &attributes) -{ - if (result == 0) - { - ++this->timer_; - ++ this->entries_; - } - - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LRU_Caching_Strategy<CONTAINER>::notify_find (int result, - ATTRIBUTES &attr) -{ - if (result == 0) - { - attr = this->timer_; - ++this->timer_; - } - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LRU_Caching_Strategy<CONTAINER>::notify_unbind (int result, - const ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LRU_Caching_Strategy<CONTAINER>::notify_trybind (int result, - ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LRU_Caching_Strategy<CONTAINER>::notify_rebind (int result, - const ATTRIBUTES &attr) -{ - if (result == 0) - ++this->timer_; - return result; -} - -template<class CONTAINER> ACE_INLINE void -ACE_LRU_Caching_Strategy<CONTAINER>::dump (void) const -{ - ACE_TRACE ("ACE_LRU_Caching_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("timer_ = %d "), this->timer_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -////////////////////////////////////////////////////////////////////////////////// - -template<class CONTAINER> ACE_INLINE -ACE_LFU_Caching_Strategy<CONTAINER>::ACE_LFU_Caching_Strategy (void) -{ -} - -template<class CONTAINER> ACE_INLINE -ACE_LFU_Caching_Strategy<CONTAINER>::~ACE_LFU_Caching_Strategy (void) -{ -} - -template<class CONTAINER> ACE_INLINE ACE_LFU_Caching_Strategy<CONTAINER>::ATTRIBUTES -ACE_LFU_Caching_Strategy<CONTAINER>::attributes (void) -{ - return 0; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LFU_Caching_Strategy<CONTAINER>::notify_bind (int result, - const ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LFU_Caching_Strategy<CONTAINER>::notify_find (int result, - ATTRIBUTES &attr) -{ - if (result == 0) - attr += 1; - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LFU_Caching_Strategy<CONTAINER>::notify_trybind (int result, - ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_LFU_Caching_Strategy<CONTAINER>::notify_rebind (int result, - const ATTRIBUTES &attr) -{ - return result; -} -template<class CONTAINER> ACE_INLINE int -ACE_LFU_Caching_Strategy<CONTAINER>::notify_unbind (int result, - const ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE void -ACE_LFU_Caching_Strategy<CONTAINER>::dump (void) const -{ - ACE_TRACE ("ACE_LFU_Caching_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -////////////////////////////////////////////////////////////////////////////////////// - -template<class CONTAINER> ACE_INLINE -ACE_FIFO_Caching_Strategy<CONTAINER>::ACE_FIFO_Caching_Strategy (ATTRIBUTES order) - : order_ (order) -{ -} - -template<class CONTAINER> ACE_INLINE -ACE_FIFO_Caching_Strategy<CONTAINER>::~ACE_FIFO_Caching_Strategy (void) -{ -} - -template<class CONTAINER> ACE_INLINE ACE_FIFO_Caching_Strategy<CONTAINER>::ATTRIBUTES -ACE_FIFO_Caching_Strategy<CONTAINER>::attributes (void) -{ - return this->order_; -} - -template<class CONTAINER> ACE_INLINE int -ACE_FIFO_Caching_Strategy<CONTAINER>::notify_bind (int result, - const ATTRIBUTES &attr) -{ - if (result == 0) - ++this->order_; - return result; -} -template<class CONTAINER> ACE_INLINE int -ACE_FIFO_Caching_Strategy<CONTAINER>::notify_find (int result, - ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_FIFO_Caching_Strategy<CONTAINER>::notify_unbind (int result, - const ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_FIFO_Caching_Strategy<CONTAINER>::notify_trybind (int result, - ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_FIFO_Caching_Strategy<CONTAINER>::notify_rebind (int result, - const ATTRIBUTES &attr) -{ - if (result == 0) - ++this->order_; - return result; -} - - -template<class CONTAINER> ACE_INLINE void -ACE_FIFO_Caching_Strategy<CONTAINER>::dump (void) const -{ - ACE_TRACE ("ACE_FIFO_Caching_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("order_ = %d "), this->order_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -////////////////////////////////////////////////////////////////////////////////// -template<class CONTAINER> ACE_INLINE -ACE_Null_Caching_Strategy<CONTAINER>::ACE_Null_Caching_Strategy (void) - : dummy_ (0) -{ -} - -template<class CONTAINER> ACE_INLINE -ACE_Null_Caching_Strategy<CONTAINER>::~ACE_Null_Caching_Strategy (void) -{ -} - -template<class CONTAINER> ACE_INLINE ACE_Null_Caching_Strategy<CONTAINER>::ATTRIBUTES -ACE_Null_Caching_Strategy<CONTAINER>::attributes (void) -{ - return this->dummy_; -} - -template<class CONTAINER> ACE_INLINE int -ACE_Null_Caching_Strategy<CONTAINER>::notify_bind (int result, - const ATTRIBUTES &attr) -{ - return result; -} -template<class CONTAINER> ACE_INLINE int -ACE_Null_Caching_Strategy<CONTAINER>::notify_find (int result, - ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_Null_Caching_Strategy<CONTAINER>::notify_unbind (int result, - const ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_Null_Caching_Strategy<CONTAINER>::notify_trybind (int result, - ATTRIBUTES &attr) -{ - return result; -} - -template<class CONTAINER> ACE_INLINE int -ACE_Null_Caching_Strategy<CONTAINER>::notify_rebind (int result, - const ATTRIBUTES &attr) -{ - return result; -} - - -template<class CONTAINER> ACE_INLINE void -ACE_Null_Caching_Strategy<CONTAINER>::dump (void) const -{ - ACE_TRACE ("ACE_Null_Caching_Strategy::dump"); - - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -////////////////////////////////////////////////////////////////////////////////// diff --git a/examples/Web_Crawler/Command_Processor.cpp b/examples/Web_Crawler/Command_Processor.cpp deleted file mode 100644 index 83d2804b221..00000000000 --- a/examples/Web_Crawler/Command_Processor.cpp +++ /dev/null @@ -1,139 +0,0 @@ - // $Id$ - -#include "URL.h" -#include "HTTP_URL.h" -#include "Options.h" -#include "Command_Processor.h" -#include "URL_Visitor.h" - -ACE_RCSID(Web_Crawler, Command_Processor, "$Id$") - -Command::~Command (void) -{ -} - -URL_Command::URL_Command (URL *url) - : url_ (url) -{ -} - -int -URL_Command::execute (void) -{ - - ACE_CString check_string (this->url_->url_addr ().get_path_name ()); - if (check_string.find ("news:") >= 0) - return 0; - - if (check_string.find (".cgi") >= 0) - return 0; - - if (check_string.find ("mailto") >= 0) - return 0; - - if (check_string.find (".gif") >= 0) - return 0; - - if (check_string.find (".pdf") >= 0) - return 0; - - if (check_string.find (".map") >= 0) - return 0; - - if (check_string.find (".bmp") >= 0) - return 0; - - if (check_string.find (".jpg") >= 0) - return 0; - - if (this->url_->accept (OPTIONS::instance ()->visitor ()) !=0) - { - ACE_DEBUG ((LM_DEBUG, - "Coudnt accept url\n")); - return -1; - } - return 0; -} - -int -URL_Command::destroy (void) -{ - delete this; - return 0; -} -Command_Processor::Command_Processor (void) -{ -} - -Command_Processor::~Command_Processor (void) -{ -} - -int -Command_Processor::destroy (void) -{ - delete this; - return 0; -return 0; -} - -int -Command_Processor::execute (void) -{ - Command *command; - while (this->url_queue_.is_empty () != 1) - { - if (this->url_queue_.dequeue_head (command) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", "dequeue_head"), - -1); - URL_Command *url_command = ACE_dynamic_cast (URL_Command *, - command); - Auto_Destroyer<URL_Command> url_command_ptr (url_command); - if (url_command_ptr->execute () != 0) - { - ACE_DEBUG ((LM_DEBUG, - "Couldnt execute command")); - return -1; - } - } - return 0; -} - -int -Command_Processor::insert (Command *command) -{ - // According to the order specified the commands are removed from the queue. - if (this->url_queue_.is_full() != 1) - { - if (ACE_OS::strcmp (OPTIONS::instance ()->order (),"FIFO") == 0) - { - if (this->url_queue_.enqueue_tail (command) !=0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", "enqueue_tail"), - - 1); - } - if (ACE_OS::strcmp (OPTIONS::instance ()->order (),"LIFO") == 0) - { - if (this->url_queue_.enqueue_head (command) !=0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", "enqueue_head"), - - 1); - } - } - return 0; -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Singleton<Options, ACE_Null_Mutex>; -template class ACE_Unbounded_Queue<Command *>; -template class ACE_Node<Command *>; -template class ACE_Unbounded_Queue_Iterator<Command *>; -template class ACE_Unbounded_Queue<Command *>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Singleton<Options, ACE_Null_Mutex> -#pragma instantiate ACE_Unbounded_Queue<Command *> -#pragma instantiate ACE_Node<Command *> -#pragma instantiate ACE_Unbounded_Queue_Iterator<Command *> -#pragma instantiate ACE_Unbounded_Queue<Command *> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/examples/Web_Crawler/Command_Processor.h b/examples/Web_Crawler/Command_Processor.h deleted file mode 100644 index 20ef1b61142..00000000000 --- a/examples/Web_Crawler/Command_Processor.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- C++ -*- */ -// $Id $ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// Command_Processor.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _COMMAND_PROCESSOR_H -#define _COMMAND_PROCESSOR_H - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Containers.h" -#include "Options.h" - -// Forward decl. -class URL; - -class Command -{ - // = TITLE - // Abstract base class for a command. - // - // = DESCRIPTION - // Each command is executed by a <Command_Processor>. -public: - virtual ~Command (void); - // Virtual destructor. - - virtual int execute (void) = 0; - // This is the entry point to execute the command. - virtual int destroy (void) = 0; -}; - -class URL_Command : public Command -{ - // = TITLE - // Defines an API for executing a command on a URL. - // - // = DESCRIPTION - // Each command is executed by a <Command_Processor>. -public: - URL_Command (URL *); - // Constructor. - - virtual int execute (void); - // Execute the URL command. - - int destroy (void); - // Commit suicide. -private: - URL *url_; - // Pointer to the URL. -}; - -class Command_Processor -{ - // = TITLE - // Execute commands that are passed to it. - // - // = DESCRIPTION - // This class implements the Command Processor pattern. -public: - Command_Processor (void); - - int insert (Command *); - // Insert a new <Command> into the <Command_Processor>'s queue. - - int execute (void); - // Execute all the <Commands> in the queue. - - int destroy (void); - // Destroy the <Command_Processor>. - -private: - friend class ACE_Shutup_GPlusPlus; - // Turn off g++ warning - - ~Command_Processor (void); - // Ensure dynamic allocation. - - // @@ You fill in here... - ACE_Unbounded_Queue<Command *> url_queue_; -}; - - -#endif /* _COMMAND_PROCESSOR_H */ diff --git a/examples/Web_Crawler/HTTP_URL.cpp b/examples/Web_Crawler/HTTP_URL.cpp deleted file mode 100644 index 45369386756..00000000000 --- a/examples/Web_Crawler/HTTP_URL.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// $Id$ - -#include "ace/Auto_Ptr.h" -#include "URL_Visitor.h" -#include "Options.h" -#include "HTTP_URL.h" - -ACE_RCSID(Web_Crawler, HTTP_URL, "$Id$") - -const ACE_URL_Addr & -HTTP_URL::url_addr (void) const -{ - return this->url_addr_; -} - -HTTP_URL::HTTP_URL (const ACE_URL_Addr &url_addr, - HTTP_URL *cp) - : url_addr_ (url_addr), - containing_page_ (cp == 0 ? this : cp) -{ - ACE_DEBUG ((LM_DEBUG, "HTTP_URL %s\n", url_addr.addr_to_string ())); -} - -int -HTTP_URL::send_request (void) -{ - /* - // Since this is HTTP 1.1 we'll need to establish a connection - // only once. Trying for relative paths. - // if (this->url_addr ().get_hostname () != url_hostname) - // { - if (this->stream ().open (this->url_addr ()) == -1) - return -1; - // }*/ - int commandsize = - ACE_OS::strlen (this->url_addr ().get_path_name ()) - + ACE_OS::strlen (this->url_addr ().get_host_name ()) - + 20 // Extra - + 1 // NUL byte - + 16; // Protocol filler... - - - char *command; - ACE_NEW_RETURN (command, - char[commandsize], - -1); - - // Ensure that the <command> memory is deallocated. - ACE_Auto_Basic_Array_Ptr<char> cmd_ptr (command); - - ACE_OS::sprintf (cmd_ptr.get (), - "GET /%s HTTP/1.1\r\n", - this->url_addr ().get_path_name ()); - - ACE_DEBUG ((LM_DEBUG, "Command:%s length %d", - cmd_ptr.get (), - ACE_OS::strlen (cmd_ptr.get ()))); - - // Send the GET command to the connected server. - if (this->stream ().send_n (cmd_ptr.get (), - ACE_OS::strlen (cmd_ptr.get ()), - ACE_const_cast (ACE_Time_Value *, - OPTIONS::instance ()->timeout ())) > 0) - { - ACE_OS::sprintf (cmd_ptr.get (), - "Host: %s\r\n\r\n", - this->url_addr ().get_host_name ()); - - ACE_DEBUG ((LM_DEBUG, "Command:%s length %d", - cmd_ptr.get (), - ACE_OS::strlen (cmd_ptr.get ()))); - - // IMP: The length of teh command has to be sent! - int retval = this->stream ().send_n (cmd_ptr.get (), - ACE_OS::strlen (cmd_ptr.get ()), - ACE_const_cast (ACE_Time_Value *, - OPTIONS::instance ()->timeout ())); - this->stream ().svc_handler ()->idle (0); //KIRTHIKA - if (retval <= 0) - return -1; - else - return retval; - } - else - return -1; -} - -int -HTTP_URL::accept (URL_Visitor *visitor) -{ - // This is part of the visitor pattern. - return visitor->visit (*this); -} - -int -HTTP_URL::destroy (void) -{ - delete this; - return 0; - // Commit suicide! -} diff --git a/examples/Web_Crawler/HTTP_URL.h b/examples/Web_Crawler/HTTP_URL.h deleted file mode 100644 index b571b1043f8..00000000000 --- a/examples/Web_Crawler/HTTP_URL.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// HTTP_URL.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _HTTP_URL_H -#define _HTTP_URL_H - -#include "URL_Status.h" -#include "URL.h" -#include "Options.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -class HTTP_URL : public URL -{ - // = TITLE - // An ADT for an HTTP URL. - // - // = DESCRIPTION - // This class plays the "element" role in the Visitor pattern. -public: - HTTP_URL (const ACE_URL_Addr &url_addr, - HTTP_URL *containing_page = 0); - // The <url_addr> is the URL that we're going to be visiting. We - // also keep track of the containing page, if any, which is used to - // print out more meaningful messages. - - virtual int accept (URL_Visitor *visitor); - // Accept the visitor, which will then perform a particular - // visitation strategy on the URL. This method is part of the - // Visitor pattern. - - virtual int send_request (void); - // Send a <GET> command to fetch the contents in the URI from the - // server. - - virtual const ACE_URL_Addr &url_addr (void) const; - // Returns the URL that we represent. - - int destroy (void); - // Commit suicide -private: - ACE_URL_Addr url_addr_; - // Address of the URL we're connected to. - - HTTP_URL *containing_page_; - // Page that contained us. -}; - -#endif /* _HTTP_URL_H */ diff --git a/examples/Web_Crawler/Iterators.cpp b/examples/Web_Crawler/Iterators.cpp deleted file mode 100644 index 199f427f0c7..00000000000 --- a/examples/Web_Crawler/Iterators.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// $Id$ - -#include "Options.h" -#include "Iterators.h" - -ACE_RCSID(Web_Crawler, Iterators, "$Id$") - -URL_Iterator::~URL_Iterator (void) -{ -} - -int -URL_Iterator::destroy (void) -{ - // Commit suicide. - delete this; - return 0; -} - -HTML_Body_Iterator::HTML_Body_Iterator (URL &url) - : url_ (url) -{ -} - -int -HTML_Body_Iterator::next (ACE_CString &url) -{ - size_t len = BUFSIZ; - const char *buf; - ACE_CString buffer; - int href_index = 0; - - for (buf = this->url_.stream ().recv (len); - buf > 0; - buf = this->url_.stream ().recv (len)) - { - - buffer.set (buf, BUFSIZ, 1); - - href_index = buffer.find ("HREF"); - - if (href_index < 0) - href_index = buffer.find ("href"); - - // Grep fpr " and grab the string until end-" - if ( href_index > 0) - { - // Get back to buffer start location. - this->url_.stream ().seek (-1 * len, SEEK_CUR); - - int start_index = buffer.find ('\"', - href_index); - if (start_index <= 0) - break; - - start_index += href_index; - - int end_index = buffer.find ('\"', - start_index + 1); - if (end_index <= 0) - break; - - end_index += start_index + 1; - - ssize_t url_len = end_index - (start_index + 1); - - ACE_CString temp = buffer.substring (start_index + 1, - url_len); - url.set (temp.c_str (), len, 1); - - this->url_.stream ().seek (end_index + 1); - - return url_len; - } - } - return 0; - -} - -HTTP_Header_Iterator::HTTP_Header_Iterator (URL &url) - : url_ (url), - end_of_header_ (0) -{ -} - -int -HTTP_Header_Iterator::next (ACE_CString &line) -{ - if (this->end_of_header_) - return 0; - else - { - for (char c; - (c = this->url_.stream ().get_char ()) != EOF; - ) - { - // Check to see if we're at the end of the header line. - if (c == '\r' && this->url_.stream ().peek_char (0) == '\n') - { - line.set (this->url_.stream ().recv (), - this->url_.stream ().recv_len () - 1, - 1); - - // Check to see if we're at the end of the header. - if (this->url_.stream ().peek_char (1) == '\r' - && this->url_.stream ().peek_char (2) == '\n') - { - this->end_of_header_ = 1; - // We're at the end of the header section. - this->url_.stream ().seek (3); - } - else - // We're at the end of the line. - this->url_.stream ().seek (1); - - return 1; - } - // Handle broken Web servers that use '\n' instead of - // '\r\n'. - else if (c == '\n') - { - line.set (this->url_.stream ().recv (), - (this->url_.stream ().recv_len ()), - 1); - - // Check to see if we're at the end of the header. - if (this->url_.stream ().peek_char (0) == '\n') - { - // We're at the end of the header section. - this->url_.stream ().seek (1); - this->end_of_header_ = 1; - } - - return 1; - } - } - - } - return 0; -} - -URL_Download_Iterator::URL_Download_Iterator (URL &url) - : url_ (url) -{ -} - -int -URL_Download_Iterator::next (ACE_CString &buffer) -{ - size_t len = BUFSIZ; - - const char *buf = this->url_.stream ().recv (len); - - - if (buf == 0) - return 0; - else - { - buffer.set (buf, len, 1); - return 1; - } -} diff --git a/examples/Web_Crawler/Iterators.h b/examples/Web_Crawler/Iterators.h deleted file mode 100644 index b171b0c2aeb..00000000000 --- a/examples/Web_Crawler/Iterators.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// Iterators.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _ITERATORS_H -#define _ITERATORS_H - -#include "URL.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -class URL_Iterator -{ - // = TITLE - // An abstract base class that defines an iterator. - // - // = DESCRIPTION - // Subclasses of this base class can define what strings - // to return from <next>. This class decouples higher-level - // software from the details of whatever type of URL header or - // body we're iterating over. -public: - // = Initialization and termination methods. - virtual int destroy (void); - // "virtual" destructor. - - // = Iterator methods. - virtual int next (ACE_CString &string) = 0; - // Pass back the next <string> that hasn't been seen yet. Returns 0 - // when all items have been seen, else 1. - -protected: - virtual ~URL_Iterator (void); - // C++ destructor. -}; - -class HTML_Body_Iterator : public URL_Iterator -{ - // = TITLE - // An iterator that returns URLs embedded in HTML files. -public: - // = Initialization and termination methods. - HTML_Body_Iterator (URL &url); - // Constructor. - - // = Iterator methods. - virtual int next (ACE_CString &url); - // Pass back the next <url> that hasn't been seen in the - // memory-mapped file. Returns 0 when all items have been seen, - // else 1. - -private: - URL &url_; - // HTTP URL that we're iterating over. -}; - -class HTTP_Header_Iterator : public URL_Iterator -{ - // = TITLE - // An iterator that iterates over the HTTP header. -public: - // = Initialization and termination methods. - HTTP_Header_Iterator (URL &url); - // Constructor. - - // = Iterator methods. - virtual int next (ACE_CString &line); - // Pass back the next <line> that hasn't been seen in the - // memory-mapped file header. Returns 0 when we've reached the end - // of the header. seen, else 1. - -private: - URL &url_; - // HTTP URL that we're iterating over. - - int end_of_header_; - // We've found the end of the header, which means this iterator is - // finished. -}; - -class URL_Download_Iterator : public URL_Iterator -{ - // = TITLE - // An iterator that iterates over the contents of an entire URL, - // i.e., both header and body, and returns it in <BUFSIZ> - // <buffer>s. -public: - // = Initialization and termination methods. - URL_Download_Iterator (URL &url); - // Constructor. - - // = Iterator methods. - virtual int next (ACE_CString &buffer); - // Pass back the next <buffer> data from the stream, where - // <buffer.size> <= <BUFSIZ> . Returns 0 when we've reached the end - // of the header, else 1. - -private: - URL &url_; - // HTTP URL that we're iterating over. -}; - -#endif /* _ITERATORS_H */ diff --git a/examples/Web_Crawler/Makefile b/examples/Web_Crawler/Makefile deleted file mode 100644 index 0e821049f83..00000000000 --- a/examples/Web_Crawler/Makefile +++ /dev/null @@ -1,1669 +0,0 @@ -#---------------------------------------------------------------------------- -# $Id$ -# -# Makefile for the Web Crawler application. -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -BIN = main - -FILES = Command_Processor \ - HTTP_URL \ - Iterators \ - Mem_Map_Stream \ - Options \ - URL \ - URL_Addr \ - URL_Status \ - URL_Visitor \ - URL_Visitor_Factory \ - Web_Crawler \ - Optimal_Cache_Map_Manager_T \ - Caching_Strategies_T \ - Cached_Connect_Strategy_T - - -SRC = $(addsuffix .cpp,$(FILES)) -OBJ = $(addsuffix .o,$(FILES)) - -BUILD = $(VBIN) - -#---------------------------------------------------------------------------- -# Include macros and targets -#---------------------------------------------------------------------------- - -include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU -include $(ACE_ROOT)/include/makeinclude/macros.GNU -include $(ACE_ROOT)/include/makeinclude/rules.common.GNU -include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU -include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU -include $(ACE_ROOT)/include/makeinclude/rules.local.GNU - -#---------------------------------------------------------------------------- -# Local targets -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Dependencies -#---------------------------------------------------------------------------- - -# DO NOT DELETE THIS LINE -- g++dep uses it. -# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. - -.obj/Command_Processor.o .obj/Command_Processor.so .shobj/Command_Processor.o .shobj/Command_Processor.so: Command_Processor.cpp URL.h Mem_Map_Stream.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/WFMO_Reactor.i \ - $(ACE_ROOT)/ace/Strategies.i \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp URL_Addr.h \ - URL_Status.h HTTP_URL.h Options.h Command_Processor.h URL_Visitor.h \ - Iterators.h Caching_Strategies_T.h Caching_Strategies_T.i \ - Caching_Strategies_T.cpp Cached_Connect_Strategy_T.h \ - Optimal_Cache_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Pair_T.h \ - $(ACE_ROOT)/ace/Pair.h \ - $(ACE_ROOT)/ace/Pair.i \ - $(ACE_ROOT)/ace/Pair_T.i \ - $(ACE_ROOT)/ace/Pair_T.cpp \ - Optimal_Cache_Map_Manager_T.i Optimal_Cache_Map_Manager_T.cpp \ - Cached_Connect_Strategy_T.i Cached_Connect_Strategy_T.cpp -.obj/HTTP_URL.o .obj/HTTP_URL.so .shobj/HTTP_URL.o .shobj/HTTP_URL.so: HTTP_URL.cpp \ - $(ACE_ROOT)/ace/Auto_Ptr.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Auto_Ptr.i \ - $(ACE_ROOT)/ace/Auto_Ptr.cpp URL_Visitor.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Strategies.i \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.i HTTP_URL.h \ - URL_Status.h URL.h Mem_Map_Stream.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp URL_Addr.h \ - Options.h Iterators.h Caching_Strategies_T.h Caching_Strategies_T.i \ - Caching_Strategies_T.cpp Cached_Connect_Strategy_T.h \ - Optimal_Cache_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Pair_T.h \ - $(ACE_ROOT)/ace/Pair.h \ - $(ACE_ROOT)/ace/Pair.i \ - $(ACE_ROOT)/ace/Pair_T.i \ - $(ACE_ROOT)/ace/Pair_T.cpp \ - Optimal_Cache_Map_Manager_T.i Optimal_Cache_Map_Manager_T.cpp \ - Cached_Connect_Strategy_T.i Cached_Connect_Strategy_T.cpp -.obj/Iterators.o .obj/Iterators.so .shobj/Iterators.o .shobj/Iterators.so: Iterators.cpp Options.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - Iterators.h URL.h Mem_Map_Stream.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/WFMO_Reactor.i \ - $(ACE_ROOT)/ace/Strategies.i \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp URL_Addr.h \ - URL_Status.h -.obj/Mem_Map_Stream.o .obj/Mem_Map_Stream.so .shobj/Mem_Map_Stream.o .shobj/Mem_Map_Stream.so: Mem_Map_Stream.cpp \ - $(ACE_ROOT)/ace/FILE_Addr.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/FILE_Addr.i \ - $(ACE_ROOT)/ace/Auto_Ptr.h \ - $(ACE_ROOT)/ace/Auto_Ptr.i \ - $(ACE_ROOT)/ace/Auto_Ptr.cpp Options.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - Mem_Map_Stream.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/WFMO_Reactor.i \ - $(ACE_ROOT)/ace/Strategies.i \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp -.obj/Options.o .obj/Options.so .shobj/Options.o .shobj/Options.so: Options.cpp \ - $(ACE_ROOT)/ace/Get_Opt.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Get_Opt.i URL_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/INET_Addr.i Options.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp -.obj/URL.o .obj/URL.so .shobj/URL.o .shobj/URL.so: URL.cpp URL.h Mem_Map_Stream.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/WFMO_Reactor.i \ - $(ACE_ROOT)/ace/Strategies.i \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp URL_Addr.h \ - URL_Status.h -.obj/URL_Addr.o .obj/URL_Addr.so .shobj/URL_Addr.o .shobj/URL_Addr.so: URL_Addr.cpp URL_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/INET_Addr.i -.obj/URL_Status.o .obj/URL_Status.so .shobj/URL_Status.o .shobj/URL_Status.so: URL_Status.cpp URL_Status.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i -.obj/URL_Visitor.o .obj/URL_Visitor.so .shobj/URL_Visitor.o .shobj/URL_Visitor.so: URL_Visitor.cpp URL_Visitor.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(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/Strategies.i \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.i HTTP_URL.h \ - URL_Status.h URL.h Mem_Map_Stream.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp URL_Addr.h \ - Options.h Iterators.h Caching_Strategies_T.h Caching_Strategies_T.i \ - Caching_Strategies_T.cpp Cached_Connect_Strategy_T.h \ - Optimal_Cache_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Pair_T.h \ - $(ACE_ROOT)/ace/Pair.h \ - $(ACE_ROOT)/ace/Pair.i \ - $(ACE_ROOT)/ace/Pair_T.i \ - $(ACE_ROOT)/ace/Pair_T.cpp \ - Optimal_Cache_Map_Manager_T.i Optimal_Cache_Map_Manager_T.cpp \ - Cached_Connect_Strategy_T.i Cached_Connect_Strategy_T.cpp \ - Command_Processor.h -.obj/URL_Visitor_Factory.o .obj/URL_Visitor_Factory.so .shobj/URL_Visitor_Factory.o .shobj/URL_Visitor_Factory.so: URL_Visitor_Factory.cpp URL_Visitor_Factory.h \ - URL_Visitor.h $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(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/Strategies.i \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.i HTTP_URL.h \ - URL_Status.h URL.h Mem_Map_Stream.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp URL_Addr.h \ - Options.h Iterators.h Caching_Strategies_T.h Caching_Strategies_T.i \ - Caching_Strategies_T.cpp Cached_Connect_Strategy_T.h \ - Optimal_Cache_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Pair_T.h \ - $(ACE_ROOT)/ace/Pair.h \ - $(ACE_ROOT)/ace/Pair.i \ - $(ACE_ROOT)/ace/Pair_T.i \ - $(ACE_ROOT)/ace/Pair_T.cpp \ - Optimal_Cache_Map_Manager_T.i Optimal_Cache_Map_Manager_T.cpp \ - Cached_Connect_Strategy_T.i Cached_Connect_Strategy_T.cpp \ - Command_Processor.h -.obj/Web_Crawler.o .obj/Web_Crawler.so .shobj/Web_Crawler.o .shobj/Web_Crawler.so: Web_Crawler.cpp Options.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - URL_Visitor_Factory.h URL_Visitor.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Strategies.i \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.i HTTP_URL.h \ - URL_Status.h URL.h Mem_Map_Stream.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp URL_Addr.h \ - Iterators.h Caching_Strategies_T.h Caching_Strategies_T.i \ - Caching_Strategies_T.cpp Cached_Connect_Strategy_T.h \ - Optimal_Cache_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Pair_T.h \ - $(ACE_ROOT)/ace/Pair.h \ - $(ACE_ROOT)/ace/Pair.i \ - $(ACE_ROOT)/ace/Pair_T.i \ - $(ACE_ROOT)/ace/Pair_T.cpp \ - Optimal_Cache_Map_Manager_T.i Optimal_Cache_Map_Manager_T.cpp \ - Cached_Connect_Strategy_T.i Cached_Connect_Strategy_T.cpp \ - Command_Processor.h Web_Crawler.h -.obj/Optimal_Cache_Map_Manager_T.o .obj/Optimal_Cache_Map_Manager_T.so .shobj/Optimal_Cache_Map_Manager_T.o .shobj/Optimal_Cache_Map_Manager_T.so: Optimal_Cache_Map_Manager_T.cpp \ - Optimal_Cache_Map_Manager_T.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Pair_T.h \ - $(ACE_ROOT)/ace/Pair.h \ - $(ACE_ROOT)/ace/Pair.i \ - $(ACE_ROOT)/ace/Pair_T.i \ - $(ACE_ROOT)/ace/Pair_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - Optimal_Cache_Map_Manager_T.i Optimal_Cache_Map_Manager_T.cpp -.obj/Caching_Strategies_T.o .obj/Caching_Strategies_T.so .shobj/Caching_Strategies_T.o .shobj/Caching_Strategies_T.so: Caching_Strategies_T.cpp \ - Caching_Strategies_T.h $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - Caching_Strategies_T.i Caching_Strategies_T.cpp -.obj/Cached_Connect_Strategy_T.o .obj/Cached_Connect_Strategy_T.so .shobj/Cached_Connect_Strategy_T.o .shobj/Cached_Connect_Strategy_T.so: Cached_Connect_Strategy_T.cpp \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-linux-lxpthreads.h \ - $(ACE_ROOT)/ace/config-linux-common.h \ - $(ACE_ROOT)/ace/config-g++-common.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - Cached_Connect_Strategy_T.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Strategies.i \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Functor.h \ - $(ACE_ROOT)/ace/Functor.i \ - $(ACE_ROOT)/ace/Functor_T.h \ - $(ACE_ROOT)/ace/Functor_T.i \ - $(ACE_ROOT)/ace/Functor_T.cpp \ - $(ACE_ROOT)/ace/Hash_Map_Manager.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ - $(ACE_ROOT)/ace/Message_Block.h \ - $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/Message_Block_T.h \ - $(ACE_ROOT)/ace/Message_Block_T.i \ - $(ACE_ROOT)/ace/Message_Block_T.cpp \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.i \ - Optimal_Cache_Map_Manager_T.h \ - $(ACE_ROOT)/ace/Pair_T.h \ - $(ACE_ROOT)/ace/Pair.h \ - $(ACE_ROOT)/ace/Pair.i \ - $(ACE_ROOT)/ace/Pair_T.i \ - $(ACE_ROOT)/ace/Pair_T.cpp \ - Optimal_Cache_Map_Manager_T.i Optimal_Cache_Map_Manager_T.cpp \ - Caching_Strategies_T.h Caching_Strategies_T.i \ - Caching_Strategies_T.cpp Cached_Connect_Strategy_T.i \ - Cached_Connect_Strategy_T.cpp - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Web_Crawler/Mem_Map_Stream.cpp b/examples/Web_Crawler/Mem_Map_Stream.cpp deleted file mode 100644 index 8baad661129..00000000000 --- a/examples/Web_Crawler/Mem_Map_Stream.cpp +++ /dev/null @@ -1,265 +0,0 @@ -// $Id$ - -#include "ace/FILE_Addr.h" -#include "ace/Auto_Ptr.h" -#include "Options.h" -#include "Mem_Map_Stream.h" - -ACE_RCSID(Web_Crawler, Mem_Map_Stream, "$Id$") - -ACE_SOCK_Stream & -Mem_Map_Stream::stream (void) -{ - return svc_handler_->peer (); - // return this->stream_; -} - -ssize_t -Mem_Map_Stream::send_n (const void *buf, size_t size, ACE_Time_Value *tv) -{ - return svc_handler_->peer ().send_n (buf, size, 0, tv); - //return this->stream_.send_n (buf, size, 0, tv); - // Needed for persistent connections. - // svc_handler_->idle (); -} - -int -Mem_Map_Stream::eof (void) const -{ - return this->get_pos_ >= this->end_of_mapping_plus1_; -} - -int -Mem_Map_Stream::get_char (void) -{ - if (this->eof () && this->grow_file_and_remap () == -1) - return EOF; - - return *this->get_pos_++; -} - -int -Mem_Map_Stream::rewind (void) -{ - //this->mem_map_.map ();// KIRTHIKA - - this->recv_pos_ = - ACE_reinterpret_cast (char *, - this->mem_map_.addr ()); - this->get_pos_ = this->recv_pos_; - this->end_of_mapping_plus1_ = - this->recv_pos_ + this->mem_map_.size (); - return 0; -} - -int -Mem_Map_Stream::peek_char (size_t offset) -{ - // We may need to iterate if the size of <n> is large. - while (this->get_pos_ + offset >= this->end_of_mapping_plus1_) - if (this->grow_file_and_remap () == -1) - return EOF; - - return this->get_pos_[offset]; -} - -const char * -Mem_Map_Stream::recv (void) const -{ - return this->recv_pos_; -} - -const char * -Mem_Map_Stream::recv (size_t &len) -{ - if (this->eof () && this->grow_file_and_remap () == -1) - return 0; - - - const char *s = this->recv_pos_; - this->seek (len, SEEK_CUR); - len = this->get_pos_ - s; - return s; -} - -size_t -Mem_Map_Stream::recv_len (void) const -{ - return this->get_pos_ - this->recv_pos_; -} - -const char * -Mem_Map_Stream::peek_str (size_t offset, - size_t size) -{ - // We will iterate if the size of <offset> is large. - while (this->get_pos_ + (offset + size) > this->end_of_mapping_plus1_) - if (this->grow_file_and_remap () == -1) - return 0; - - return &this->get_pos_[offset]; -} - -off_t -Mem_Map_Stream::seek (off_t offset, int whence) -{ - switch (whence) - { - case SEEK_SET: - this->get_pos_ = - ACE_reinterpret_cast (char *, - this->mem_map_.addr ()) - + offset; - break; - - case SEEK_CUR: - this->get_pos_ += offset; - break; - - case SEEK_END: - this->get_pos_ = - this->end_of_mapping_plus1_ + offset; - // @@ Not sure how to implement this (yet). - ACE_NOTSUP_RETURN (-1); - break; - } - - // Make sure that the backing store will cover this. - while (this->get_pos_ > this->end_of_mapping_plus1_) - if (this->grow_file_and_remap () == -1) - return (off_t) -1; - - this->recv_pos_ = this->get_pos_; - return this->recv_pos_ - ACE_reinterpret_cast (char *, - this->mem_map_.addr ()); -} - -Mem_Map_Stream::Svc_Handler * -Mem_Map_Stream::svc_handler (void) -{ - return this->svc_handler_; -} - - -int -Mem_Map_Stream::open (STRAT_CONNECTOR *connector, - const ACE_INET_Addr &addr) -{ - svc_handler_ = 0; // Check whether this stopping me form checking autopurging! - //Kirthika Apr22 1615 - - ACE_DEBUG ((LM_DEBUG, - "Mem_Map_Stream :: open ()\n")); - // Connect to the server at <addr>. If the handler has to be - // connected to the server again, the Cachind strategy takes care - // and uses the same connection. - if (connector->connect (svc_handler_, - addr) == -1) - { - cout <<"CONNECT ERROR"<<errno<<endl; - ACE_ERROR_RETURN ((LM_ERROR, - "%p %s %d\n", - "Connect failed", - addr.get_host_name (), - addr.get_port_number ()), - -1); - } - // Create a temporary filename. - ACE_FILE_Addr file (ACE_sap_any_cast (ACE_FILE_Addr &)); - - // Create the temporary file via the <ACE_Mem_Map> class API. - if (this->mem_map_.open (file.get_path_name (), - O_RDWR | O_CREAT | O_APPEND, - ACE_DEFAULT_FILE_PERMS) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "open"), - -1); - // Make sure to unlink this right away so that if this process - // crashes these files will be removed automatically. -#if 0 - else if (ACE_OS::unlink (file.get_path_name ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "unlink"), - -1); - else -#endif - // Initialize all the position pointers to 0. - this->rewind (); - - return 0; -} - -int -Mem_Map_Stream::grow_file_and_remap (void) -{ - char buf[BUFSIZ + 1]; - - // Copy the next chunk of bytes from the socket into the temporary - // file. - ACE_Time_Value tv (*OPTIONS::instance ()->timeout ()); - /*ssize_t n = this->stream_.recv (buf, - sizeof buf, - &tv);*/ - - ssize_t n = this->svc_handler_->peer ().recv_n (buf, - sizeof buf, - 0, - &tv); - /*ACE_DEBUG ((LM_DEBUG, - "Recv: %d \n %s\n", - n, buf)); - */ - if (n == -1) - { - if (OPTIONS::instance ()->debug ()) - ACE_ERROR ((LM_ERROR, - "%p\n", - "recv")); - return -1; - } - else if (n == 0) - return -1; - else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "write_n"), - -1); - - // Grow the memory-mapping to encompass the entire temporary file. - if (this->mem_map_.map (-1, - PROT_RDWR, - ACE_MAP_PRIVATE | ACE_MAP_FIXED, - ACE_DEFAULT_BASE_ADDR) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "map"), - -1); - // MAP_FAILED is used as a "first time in" flag. - if (this->recv_pos_ == MAP_FAILED) - { - this->recv_pos_ = ACE_reinterpret_cast (char *, - this->mem_map_.addr ()); - this->get_pos_ = this->recv_pos_; - } - - this->end_of_mapping_plus1_ = - ACE_reinterpret_cast (char *, - this->mem_map_.addr ()) - + this->mem_map_.size (); - - // this->svc_handler_->idle ();//KIRTHIKA - - return 0; -} - -Mem_Map_Stream::~Mem_Map_Stream (void) -{ - - ACE_DEBUG ((LM_DEBUG, "~MEM_MAP:\n")); - - // Remove the mapping and the file. - this->mem_map_.remove (); -} - diff --git a/examples/Web_Crawler/Mem_Map_Stream.h b/examples/Web_Crawler/Mem_Map_Stream.h deleted file mode 100644 index 091fdf7da67..00000000000 --- a/examples/Web_Crawler/Mem_Map_Stream.h +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// Mem_Map_Stream.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _MEM_MAP_STREAM_H -#define _MEM_MAP_STREAM_H - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/SOCK_Stream.h" -#include "ace/Mem_Map.h" -#include "ace/SOCK_Connector.h" -#include "ace/Connector.h" -#include "ace/Svc_Handler.h" -#include "ace/Strategies_T.h" -#include "ace/Synch_T.h" - -class Mem_Map_Stream -{ - // = TITLE - // Provides a memory-mapped stream abstraction to simplify parsing - // of tokens. - // - // = DESCRIPTION - // This class makes it possible to treat an connection as a stream - // of bytes, similar to the C library stdio streams. The contents - // of the connection are buffered incrementally in a memory-mapped - // file. This class maintains pointers to two positions in the - // stream: - // - // 1. The <recv> position, which keeps track of the beginning of a - // token that is in the stream. - // - // 2. The <get> position, which moves along character-by-character - // until the end of the token is reached. - // - // Once a token has been located, it can be extracted from the - // stream by calling the <recv>. The length of the token, i.e., - // the <recv_len>, is the length in bytes between the <get> - // position and the <recv> position. Once the token has been - // extracted, the <recv> and <get> positions can be updated by the - // <seek> method. - -public: - typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> Svc_Handler; - - typedef ACE_Strategy_Connector<Svc_Handler, - ACE_SOCK_CONNECTOR> - STRAT_CONNECTOR; - - // Mem_Map_Stream (void); - // constructor added:KIRTHIKA - virtual int open (STRAT_CONNECTOR *connector, - const ACE_INET_Addr &); - // Initialize this object. - - virtual ~Mem_Map_Stream (void); - // Destructor. - - // = Accessor. - ACE_SOCK_Stream &stream (void); - // Returns the underlying <ACE_SOCK_Stream>. - - // = I/O methods. - - virtual ssize_t send_n (const void *buf, - size_t size, - ACE_Time_Value *tv = 0); - // Send <size> bytes in <buf> to the connected peer. This is a - // completely unbuffered call. - - virtual int get_char (void); - // Return the next character in the stream and advance the <get> - // position. Returns EOF when the <get> position reaches the end of - // the HTTP stream. - - virtual const char *recv (size_t &len); - // Returns a pointer to array of at most <len> characters starting - // at the <recv> position. If the <recv> position + <len> extends - // past the EOF then <len> is set to the number of characters - // between the <recv> position and the EOF and both the <get> and - // <recv> positions are advanced by <len>. Returns 0 if the <recv> - // position is at the EOF. - - virtual const char *recv (void) const; - // Returns a pointer to array of characters starting at the <recv> - // position. - - virtual size_t recv_len (void) const; - // Returns the length in bytes between the <get> position and the - // <recv> position. - - virtual int rewind (void); - // Resets the <get> and <recv> positions to the beginning of the - // stream. This works since all the data has been cached in the - // memory-mapped backing store. - - virtual int peek_char (size_t offset); - // Returns the nth character <offset> from the <get> position in the - // stream without advancing the <get> position. Automatically - // extends the backing store if necessary. Returns EOF if <offset> - // is past the end of the stream. - - virtual const char *peek_str (size_t offset, size_t size); - // Return a pointer to an array of <size> characters starting at - // <offset> characters from the <get> position in the stream without - // advancing the <get> position. Automatically extends the backing - // store if necessary. Returns 0 if <offset> or <offset + size> is - // past the end of the stream. - - virtual off_t seek (off_t offset, int whence = SEEK_CUR); - // Sets the <get> and <recv> positions as follows: - // o If <whence> is <SEEK_SET>, the positions are set to <offset> - // bytes from the start of the stream. - // - // o If <whence> is <SEEK_CUR>, the positions are set to the - // current <get> position plus <offset>. - // - // o If <whence> is <SEEK_END>, the positions are set to the size - // of the stream plus <offset>. - - virtual int eof (void) const; - // Returns 1 if we're at the end of the HTTP stream, else 0. - - - /* - typedef ACE_NOOP_Creation_Strategy<Svc_Handler> - NULL_CREATION_STRATEGY; - typedef ACE_NOOP_Concurrency_Strategy<Svc_Handler> - NULL_ACTIVATION_STRATEGY; - typedef ACE_Cached_Connect_Strategy<Svc_Handler, - ACE_SOCK_CONNECTOR, - ACE_SYNCH_NULL_MUTEX> - CACHED_CONNECT_STRATEGY;*/ - - Svc_Handler *svc_handler (void); - -private: - int grow_file_and_remap (void); - // Grow the file by reading another chunk from the HTTP socket and - // extend the mapping to cover this chunk. Returns -1 on failure or - // EOF, else 0. - - //ACE_SOCK_Stream stream_; - - Svc_Handler *svc_handler_; - // Connection to peer. The granularity is at the Svc_Handler level. - // The Svc_Handler has an SOCK_Stream. - /* - NULL_CREATION_STRATEGY creation_strategy_; - NULL_ACTIVATION_STRATEGY activation_strategy_; - // Configure the Strategy Connector with a strategy that caches - // connection. - CACHED_CONNECT_STRATEGY caching_connect_strategy_; - - STRAT_CONNECTOR *strat_connector_; */ - - ACE_Mem_Map mem_map_; - // Memory-mapped file that we're iterating over. - - char *recv_pos_; - // Pointer to the address where the next <recv> method will start. - - char *get_pos_; - // Pointer to the address where the next <get_char> method will - // start. - - char *end_of_mapping_plus1_; - // Address at the end of the file mapping. - -}; - -#endif /* _MEM_MAP_STREAM_H */ - diff --git a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.cpp b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.cpp deleted file mode 100644 index e0ca775f066..00000000000 --- a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.cpp +++ /dev/null @@ -1,446 +0,0 @@ -// $Id$ - -#ifndef ACE_OPTIMAL_CACHE_MAP_MANAGER_T_C -#define ACE_OPTIMAL_CACHE_MAP_MANAGER_T_C - -#define ACE_BUILD_DLL - -#include "Optimal_Cache_Map_Manager_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Malloc.h" - -#if !defined (__ACE_INLINE__) -#include "Optimal_Cache_Map_Manager_T.i" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(Web_Crawler, Optimal_Cache_Map_Manager_T, "$Id$") - -ACE_ALLOC_HOOK_DEFINE(ACE_Optimal_Cache_Map_Manager) - -ACE_ALLOC_HOOK_DEFINE(ACE_Optimal_Cache_Map_Iterator) - -ACE_ALLOC_HOOK_DEFINE(ACE_Optimal_Cache_Map_Reverse_Iterator) - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::bind (const KEY &key, - const VALUE &value) -{ - // Insert an entry which has the <key> and the <cache_value> which - // is the combination of the <value> and the attributes of the - // caching strategy. - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int bind_result = this->map_.bind (key, - cache_value); - if (bind_result != -1) - { - int result = this->caching_strategy_.notify_bind (bind_result, - cache_value.second ()); - if (result == -1) - { - this->map_.unbind (key); - - // Unless the notification goes thru the bind operation is - // not complete. - bind_result = -1; - } - } - return bind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>:: bind (const KEY &key, - const VALUE &value, - ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::CACHE_ENTRY *&entry) -{ - // Insert a entry which has the <key> and the <cache_value> which is - // the combination of the <value> and the attributes of the caching - // strategy. - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int bind_result = this->map_.bind (key, - cache_value, - entry); - if (bind_result != -1) - { - int result = this->caching_strategy_.notify_bind (bind_result, - cache_value.second ()); - - if (result == -1) - { - this->map_.unbind (key); - - // Unless the notification goes thru the bind operation is - // not complete. - bind_result = -1; - } - } - return bind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::rebind (const KEY &key, - const VALUE &value) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int rebind_result = this->map_.rebind (key, - cache_value); - if (rebind_result != -1) - { - int result = this->caching_strategy_.notify_rebind (rebind_result, - cache_value.second ()); - if (result == -1) - { - this->map_.unbind (key); - - // Unless the notification goes thru the rebind operation is - // not complete. - rebind_result = -1; - } - } - - return rebind_result; -} - - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::rebind (const KEY &key, - const VALUE &value, - VALUE &old_value) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - CACHE_VALUE old_cache_value (old_value, - this->caching_strategy_.attributes ()); - - int rebind_result = this->map_.rebind (key, - cache_value, - old_cache_value); - if (rebind_result != -1) - { - int result = this->caching_strategy_.notify_rebind (rebind_result, - cache_value.second ()); - - if (result == -1) - { - this->map_.unbind (key); - - // Unless the notification goes thru the rebind operation is - // not complete. - rebind_result = -1; - } - else - { - old_value = old_cache_value.first (); - } - } - return rebind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::rebind (const KEY &key, - const VALUE &value, - KEY &old_key, - VALUE &old_value) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - CACHE_VALUE old_cache_value (old_value, - this->caching_strategy_.attributes ()); - - int rebind_result = this->map_.rebind (key, - cache_value, - old_key, - old_cache_value); - if (rebind_result != -1) - { - int result = this->caching_strategy_.notify_rebind (rebind_result, - cache_value.second ()); - - if (result == -1) - { - this->map_.unbind (key); - - // Unless the notification goes thru the rebind operation is - // not complete. - rebind_result = -1; - } - else - { - old_value = old_cache_value.first (); - } - } - return rebind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::rebind (const KEY &key, - const VALUE &value, - ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::CACHE_ENTRY *&entry) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int rebind_result = this->map_.rebind (key, - cache_value, - entry); - if (rebind_result != -1) - { - int result = this->caching_strategy_.notify_rebind (rebind_result, - cache_value.second ()); - if (result == -1) - { - this->map_.unbind (key); - - // Unless the notification goes thru the rebind operation is - // not complete. - rebind_result = -1; - } - } - return rebind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::trybind (const KEY &key, - VALUE &value) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int trybind_result = this->map_.trybind (key, - cache_value); - - if (trybind_result != -1) - { - int result = this->caching_strategy_.notify_trybind (trybind_result, - cache_value.second ()); - if (result == -1) - { - // If the entry has got inserted into the map, it is removed - // due to failure. - if (trybind_result == 0) - this->map_.unbind (key); - - trybind_result = -1; - } - else - { - // If an attempt is made to bind an existing entry the value - // is overwritten with the value from the map. - if (trybind_result == 1) - value = cache_value.first (); - } - } - - return trybind_result; -} -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::trybind (const KEY &key, - VALUE &value, - ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::CACHE_ENTRY *&entry) -{ - CACHE_VALUE cache_value (value, - this->caching_strategy_.attributes ()); - - int trybind_result = this->map_.trybind (key, - cache_value, - entry); - - if (trybind_result != -1) - { - int result = this->caching_strategy_.notify_trybind (trybind_result, - cache_value.second ()); - if (result == -1) - { - // If the entry has got inserted into the map, it is removed - // due to failure. - if (trybind_result == 0) - this->map_.unbind (key); - - trybind_result = -1; - } - else - { - // If an attempt is made to bind an existing entry the value - // is overwritten with the value from the map. - if (trybind_result == 1) - value = cache_value.first (); - } - } - - return trybind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::find (const KEY& key, - VALUE &value) -{ - // Lookup the key and populate the <value>. - CACHE_VALUE cache_value; - - int find_result = this->map_.find (key, - cache_value); - - if (find_result != -1) - { - int result = this->caching_strategy_.notify_find (find_result, - cache_value.second ()); - // Unless the find and notification operations go thru, this - // method is not successful. - - if (result == -1) - find_result = -1; - else - { - // Since the <cache_value> has now changed after the - // notification, we need to bind to the map again. - int rebind_result = this->map_.rebind (key, - cache_value); - if (rebind_result == -1) - find_result = -1; - else - value = cache_value.first (); - } - } - - return find_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::find (const KEY &key) -{ - // Lookup the key and populate the <value>. - CACHE_VALUE cache_value; - - int find_result = this->map_.find (key, - cache_value); - if (find_result != -1) - { - int result = this->caching_strategy_.notify_find (find_result, - cache_value.second ()); - // Unless the find and notification operations go thru, this - // method is not successful. - if (result == -1) - find_result = -1; - else - { - // Since the <cache_value> has now changed after the - // notification, we need to bind to the map again. - int rebind_result = this->map_.rebind (key, - cache_value); - if (rebind_result == -1) - find_result = -1; - } - } - return find_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::find (const KEY &key, - ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::CACHE_ENTRY *&entry) -{ - // @@ No rebind in this case! - - // Lookup the key and populate the <value>. - int find_result = this->map_.find (key, - entry); - if (find_result != -1) - { - int result = this->caching_strategy_.notify_find (find_result, - entry->int_id_.second ()); - // Unless the find and notification operations go thru, this - // method is not successful. - if (result == -1) - find_result = -1; - else - { - // Since the <cache_value> has now changed after the - // notification, we need to bind to the map again. - int rebind_result = this->map_.rebind (key, - entry->int_id_); - if (rebind_result == -1) - find_result = -1; - } - } - return find_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::unbind (const KEY &key) -{ - // Remove the entry from the cache. - CACHE_VALUE cache_value; - - int unbind_result = this->map_.unbind (key, - cache_value); - - if (unbind_result != -1) - { - int result = this->caching_strategy_.notify_unbind (unbind_result, - cache_value.second ()); - - if (result == -1) - unbind_result = -1; - } - - return unbind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::unbind (const KEY &key, - VALUE &value) -{ - // Remove the entry from the cache. - CACHE_VALUE cache_value; - - int unbind_result = this->map_.unbind (key, - cache_value); - - if (unbind_result != -1) - { - int result = this->caching_strategy_.notify_unbind (unbind_result, - cache_value.second ()); - if (result == -1) - unbind_result = -1; - else - value = cache_value.first (); - } - - return unbind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::unbind (ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::CACHE_ENTRY *entry) -{ - // Remove the entry from the cache. - int unbind_result = this->map_.unbind (entry); - - if (unbind_result != -1) - { - int result = this->caching_strategy_.notify_unbind (unbind_result, - entry->int_id_.second ()); - if (result == -1) - unbind_result = -1; - } - - return unbind_result; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> void -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::dump (void) const -{ - this->map_.dump (); - this->caching_strategy_.dump (); -} - -#endif /* ACE_OPTIMAL_CACHE_MAP_MANAGER_T_C */ diff --git a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.h b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.h deleted file mode 100644 index 31a707638e1..00000000000 --- a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.h +++ /dev/null @@ -1,385 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// Optimal_Cache_Map_Manager.h -// -// = AUTHOR -// Kirthika Parameswaran <kirthika@cs.wustl.edu> -// -// ============================================================================ - -#ifndef OPTIMAL_CACHE_MAP_MANAGER_T_H -#define OPTIMAL_CACHE_MAP_MANAGER_T_H - -#include "ace/OS.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Pair_T.h" -#include "ace/Hash_Map_Manager_T.h" - -// Forward declaration. -class ACE_Allocator; - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> -class ACE_Optimal_Cache_Map_Iterator; - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> -class ACE_Optimal_Cache_Map_Reverse_Iterator; - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> -class ACE_Optimal_Cache_Map_Manager -{ - // = TITLE - // Defines a abstraction which will purge entries from a map. - // The map considered is the ACE_Hash_Map_Manager. - // - // = DESCRIPTION - - // The Optimal_Cache_Map_Manager will manage the map it contains - // and provide purging on demand from the map. The strategy for - // caching is decided by the user and provided to the Cache - // Manager. The Cache Manager acts as a agent and communicates - // between the Map and the Strategy for purging entries from the - // map. To tap the optimal methods like find(key,value,entry) - // present in the ACE_Hash_Map_Manager, - // Optimal_Cache_Map_Manager provides extra functionality on top - // of the Cache_Map_Manager. - // - // No locking mechanism provided since locking at this level - // isnt efficient. Locking has to be provided by the - // application. -public: - - // = Traits. - typedef KEY key_type; - typedef VALUE mapped_type; - - typedef ACE_TYPENAME CACHING_STRATEGY::ATTRIBUTES ATTRIBUTES; - typedef ACE_Pair<VALUE, ATTRIBUTES> CACHE_VALUE; - // The actual value mapped to the key in the map. The <attributes> - // are used by the strategy and is transparent to the user of this - // class. - - typedef ACE_Hash_Map_Manager_Ex<KEY, CACHE_VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> MAP; - typedef ACE_Hash_Map_Entry<KEY, CACHE_VALUE> CACHE_ENTRY; - - friend class ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>; - friend class ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>; - - // = ACE-style iterator typedefs. - typedef ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> ITERATOR; - typedef ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> REVERSE_ITERATOR; - - // = STL-style iterator typedefs. - typedef ITERATOR iterator; - typedef REVERSE_ITERATOR reverse_iterator; - - // = Initialization and termination methods. - ACE_Optimal_Cache_Map_Manager (ACE_Allocator *alloc = 0, - ATTRIBUTES attributes = 0, - int purge_percent = 10); - // Initialize a <Optimal_Cache_Map_Manager> with the <ACE_DEFAULT_MAP_SIZE>. - - ACE_Optimal_Cache_Map_Manager (size_t size, - ACE_Allocator *alloc = 0, - ATTRIBUTES attributes = 0, - int purge_percent = 10 ); - // Initialize a <Optimal_Cache_Map_Manager> with <size> entries. - - ~ACE_Optimal_Cache_Map_Manager (void); - // Close down a <Optimal_Cache_Map_Manager> and release dynamically allocated - // resources. - - int open (size_t length = ACE_DEFAULT_MAP_SIZE, - ACE_Allocator *alloc = 0); - // Initialise a cache with size <length>. - - int close (void); - // Close down a cache and release dynamically allocated resources. - - int bind (const KEY &key, - const VALUE &value); - // Associate <key> with <value>. If <key> is already in the - // MAP then the ENTRY is not changed. Returns 0 if a new entry is - // bound successfully, returns 1 if an attempt is made to bind an - // existing entry, and returns -1 if failures occur. - - int bind (const KEY &key, - const VALUE &value, - ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry); - // Same as a normal bind, except the cache entry is also passed back - // to the caller. The entry in this case will either be the newly - // created entry, or the existing one. - - int find (const KEY &key, - VALUE &value); - // Loopkup entry<key,value> in the cache. - - int find (const KEY &key); - // Is <key> in the cache? - - int find (const KEY &key, - ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry); - // Obtain the entry when the find succeeds. - - int rebind (const KEY &key, - const VALUE &value); - // Reassociate the <key> with <value>. If the <key> already exists - // in the cache then returns 1, on a new bind returns 0 and returns - // -1 in case of any failures. - - int rebind (const KEY &key, - const VALUE &value, - VALUE &old_value); - // Reassociate <key> with <value>, storing the old value into the - // "out" parameter <old_value>. The function fails if <key> is not - // in the cache for caches that do not allow user specified keys. - // However, for caches that allow user specified keys, if the key is - // not in the cache, a new <key>/<value> association is created. - - int rebind (const KEY &key, - const VALUE &value, - KEY &old_key, - VALUE &old_value); - // Reassociate <key> with <value>, storing the old key and value - // into the "out" parameters <old_key> and <old_value>. The - // function fails if <key> is not in the cache for caches that do not - // allow user specified keys. However, for caches that allow user - // specified keys, if the key is not in the cache, a new <key>/<value> - // association is created. - - int rebind (const KEY &key, - const VALUE &value, - ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry); - // Same as a normal rebind, except the cache entry is also passed back - // to the caller. The entry in this case will either be the newly - // created entry, or the existing one. - - int trybind (const KEY &key, - VALUE &value); - // Associate <key> with <value> if and only if <key> is not in the - // cache. If <key> is already in the cache, then the <value> parameter - // is overwritten with the existing value in the cache. Returns 0 if a - // new <key>/<value> association is created. Returns 1 if an - // attempt is made to bind an existing entry. This function fails - // for maps that do not allow user specified keys. - - int trybind (const KEY &key, - VALUE &value, - ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry); - // Same as a normal trybind, except the cache entry is also passed - // back to the caller. The entry in this case will either be the - // newly created entry, or the existing one. - - int unbind (const KEY &key); - // Remove <key> from the cache. - - int unbind (const KEY &key, - VALUE &value); - // Remove <key> from the cache, and return the <value> associated with - // <key>. - - int unbind (ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *entry); - // Remove entry from map. - - int purge (void); - // Remove entries from the cache depending upon the strategy. - - size_t current_size (void); - // Return the current size of the cache. - - size_t total_size (void); - // Return the total size of the cache. - - void dump (void) const; - // Dumps the state of the object. - - // = STL styled iterator factory functions. - - ITERATOR begin (void); - ITERATOR end (void); - // Return forward iterator. - - REVERSE_ITERATOR rbegin (void); - REVERSE_ITERATOR rend (void); - // Return reverse iterator. - -protected: - - ACE_Hash_Map_Manager_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &map (void); - // The map managed by the Optimal_Cache_Map_Manager. - - CACHING_STRATEGY &caching_strategy (void); - // The caching strategy used on the cache. - - ACE_Hash_Map_Manager_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> map_; - // The underlying map which needs to be cached. - - CACHING_STRATEGY caching_strategy_; - // The strategy to be followed for caching entries in the map. -}; -//////////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> -class ACE_Optimal_Cache_Map_Iterator -{ - // = TITLE - // Defines a iterator for the Optimal_Cache_Map_Manager. - // - // = DESCRIPTION - // Implementation to be provided by the iterator of the map - // managed by the ACE_Optimal_Cache_Map_Manager. - -public: - - // = Traits. - typedef ACE_TYPENAME CACHING_STRATEGY::ATTRIBUTES ATTRIBUTES; - typedef ACE_Pair <VALUE, ATTRIBUTES> CACHE_VALUE; - // The actual value mapped to the key in the cache. The <attributes> - // are used by the strategy and is transperant to the cache user. - - typedef ACE_Reference_Pair<KEY, VALUE> value_type; - typedef ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> IMPLEMENTATION; - // = Initialisation and termination methods. - - ACE_Optimal_Cache_Map_Iterator (const ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &iterator_impl); - - ACE_Optimal_Cache_Map_Iterator (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); - // Copy constructor. - - ~ACE_Optimal_Cache_Map_Iterator (void); - - // = Iteration methods. - - ACE_Optimal_Cache_Map_Iterator &operator= (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); - // assignment operator. - - int operator== (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); - int operator!= (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); - // Comparision operators. - - ACE_Reference_Pair<KEY, VALUE> operator* (void) const; - // Returns a reference to the internal element <this> is pointing to. - - // = STL styled iteration, compare, and reference functions. - - ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &operator++ (void); - // Prefix advance - - ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> operator++ (int); - // Postfix advance. - - ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &operator-- (void); - // Prefix reverse. - - ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> operator-- (int); - // Postfix reverse. - - ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> iterator_implementation (void) const; - // Returns the iterator of the internal map in the custody of the Optimal_Cache_Map_Manager. - - void dump (void) const; - // Dump the state of an object. - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - -protected: - ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> iterator_implementation_; - // The actual iterator which iterates internally on the map - // belonging to the Optimal_Cache_Map_Manager. -}; - -//////////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> -class ACE_Optimal_Cache_Map_Reverse_Iterator -{ - // = TITLE - // Defines a reverse iterator for the Optimal_Cache_Map_Manager. - // - // = DESCRIPTION - // Implementation to be provided by the reverse iterator of the map - // managed by thr Optimal_Cache_Map_manager. - -public: - - // = Traits. - typedef ACE_TYPENAME CACHING_STRATEGY::ATTRIBUTES ATTRIBUTES; - typedef ACE_Pair <VALUE, ATTRIBUTES> CACHE_VALUE; - // The actual value mapped to the key in the cache. The <attributes> - // are used by the strategy and is transperant to the cache user. - - typedef ACE_Reference_Pair<KEY, VALUE> value_type; - typedef ACE_Hash_Map_Reverse_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> REVERSE_IMPLEMENTATION; - // = Initialisation and termination methods. - - ACE_Optimal_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl); - - ACE_Optimal_Cache_Map_Reverse_Iterator (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); - // Copy constructor. - - ~ACE_Optimal_Cache_Map_Reverse_Iterator (void); - - // = Iteration methods. - - ACE_Optimal_Cache_Map_Reverse_Iterator &operator= (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); - // Assignment operator. - - int operator== (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); - int operator!= (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); - // Comparision operators. - - ACE_Reference_Pair<KEY, VALUE> operator* (void) const; - // Returns a reference to the internal element <this> is pointing to. - - // = STL styled iteration, compare, and reference functions. - - ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &operator++ (void); - // Prefix advance - - ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> operator++ (int); - // Postfix advance. - - ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &operator-- (void); - // Prefix reverse. - - ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> operator-- (int); - // Postfix reverse. - - ACE_Hash_Map_Reverse_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> iterator_implementation (void) const; - // Returns the iterator of the internal map in the custody of the Optimal_Cache_Map_Manager. - - void dump (void) const; - // Dump the state of an object. - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - -protected: - ACE_Hash_Map_Reverse_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> reverse_iterator_implementation_; - // The actual iterator which iterates internally on the map - // belonging to the Optimal_Cache_Map_Manager. -}; - -#if defined (__ACE_INLINE__) -#include "Optimal_Cache_Map_Manager_T.i" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "Optimal_Cache_Map_Manager_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation "Optimal_Cache_Map_Manager_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - - -#endif /* OPTIMAL_CACHE_MAP_MANAGER_T_H */ diff --git a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.i b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.i deleted file mode 100644 index 99c13e20c28..00000000000 --- a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.i +++ /dev/null @@ -1,289 +0,0 @@ -/* -*- C++ -*- */ -//$Id$ - -// @@ don't inline this -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Manager (ACE_Allocator *alloc, - ATTRIBUTES attributes, - int purge_percent) - :map_ (alloc), - // @@ Remove attributes and purge_percent from the constructor of the caching strategy - caching_strategy_ (map_, attributes, purge_percent) - - // @@ Add the ability for the user to pass in a caching strategy. -{ -} - - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Manager (size_t size, - ACE_Allocator *alloc, - ATTRIBUTES attributes, - int purge_percent) - :map_ (size, - alloc), - caching_strategy_ (map_, attributes, purge_percent) -{ -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::~ACE_Optimal_Cache_Map_Manager (void) -{ -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::open (size_t length, - ACE_Allocator *alloc) -{ - return this->map_.open (length, - alloc); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::purge (void) -{ - // @@ Remove debugging statements. - ACE_DEBUG ((LM_DEBUG, "ACE_Optimal_Cache_Map_Manager::PURGE\n")); - - // @@ Why does this need the map again? Didn't we pass this in the - // constructor? - return this->caching_strategy ().clear_cache (this->map ()); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE size_t -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::current_size (void) -{ - return this->map_.current_size (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE size_t -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::total_size (void) -{ - return this->map_.total_size (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::close (void) -{ - return this->map_.close (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::MAP & -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::map (void) -{ - return this->map_; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE CACHING_STRATEGY & -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::caching_strategy (void) -{ - return this->caching_strategy_; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::begin (void) -{ - return ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR (this->map_.begin ()); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::end (void) -{ - return ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR (this->map_.end ()); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::REVERSE_ITERATOR -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::rbegin (void) -{ - return ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::REVERSE_ITERATOR (this->map_.rbegin ()); -} -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::REVERSE_ITERATOR -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::rend (void) -{ - return ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::REVERSE_ITERATOR (this->map_.rend ()); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Iterator (const ACE_Optimal_Cache_Map_Iterator <KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) - : iterator_implementation_ (rhs.iterator_implementation ()) -{ -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::~ACE_Optimal_Cache_Map_Iterator (void) -{ -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator= (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) -{ - this->iterator_implementation_ = rhs.iterator_implementation (); - return *this; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator== (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) -{ - return this->iterator_implementation_ == rhs.iterator_implementation (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator!= (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) -{ - return this->iterator_implementation_ != rhs.iterator_implementation (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator* (void) const -{ - value_type retv ((*this->iterator_implementation_).ext_id_, (*this->iterator_implementation_).int_id_.first ()); - return retv; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator++ (void) -{ - ++this->iterator_implementation_; - return *this; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator++ (int) -{ - ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> retn = *this; - ++this->iterator_implementation_; - return retn; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator-- (void) -{ - --this->iterator_implementation_; - return *this; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator-- (int) -{ - ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> retn = *this; - --this->iterator_implementation_; - return *this; -} - - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE void -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::dump (void) const -{ - return this->iterator_implementation_.dump (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Iterator (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::IMPLEMENTATION &iterator_impl) - : iterator_implementation_ (iterator_impl) -{ -} - -// @@ Don't pass this return value by value. Pass it back via reference. -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::IMPLEMENTATION -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::iterator_implementation (void) const -{ - return this->iterator_implementation_; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// @@ Fix reverse iterator similar to the regular iterator - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Reverse_Iterator (const ACE_Optimal_Cache_Map_Reverse_Iterator <KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) - : reverse_iterator_implementation_ (rhs.iterator_implementation ()) -{ -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::~ACE_Optimal_Cache_Map_Reverse_Iterator (void) -{ -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator= (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) -{ - this->reverse_iterator_implementation_ = rhs.iterator_implementation (); - return *this; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator== (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) -{ - return this->reverse_iterator_implementation_ == rhs.iterator_implementation (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator!= (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) -{ - return this->reverse_iterator_implementation_ != rhs.iterator_implementation (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator* (void) const -{ - value_type retv ((*this->reverse_iterator_implementation_).ext_id_, (*this->reverse_iterator_implementation_).int_id_.first ()); - return retv; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator++ (void) -{ - this->reverse_iterator_implementation_.operator++ (); - return *this; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator++ (int) -{ - this->reverse_iterator_implementation_.operator++ (1); - return *this; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator-- (void) -{ - this->reverse_iterator_implementation_.operator-- (); - return *this; -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator-- (int) -{ - this->reverse_iterator_implementation_.operator-- (1); - return *this; -} - - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE void -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::dump (void) const -{ - return this->reverse_iterator_implementation_.dump (); -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Reverse_Iterator (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::REVERSE_IMPLEMENTATION &iterator_impl) - : reverse_iterator_implementation_(iterator_impl) -{ -} - -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::REVERSE_IMPLEMENTATION -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::iterator_implementation (void) const -{ - return this->reverse_iterator_implementation_; -} diff --git a/examples/Web_Crawler/Options.cpp b/examples/Web_Crawler/Options.cpp deleted file mode 100644 index 14d862dd5c4..00000000000 --- a/examples/Web_Crawler/Options.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// $Id$ - -#include "ace/Get_Opt.h" -#include "URL_Addr.h" -#include "Options.h" - -ACE_RCSID(Web_Crawler, Options, "$Id$") - -int -Options::parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt getopt (argc, argv, ASYS_TEXT ("df:h:i:l:rt:u:vo:p:")); - - ACE_LOG_MSG->open (argv[0]); - - this->hostname_ = "www.cs.wustl.edu"; - this->uri_ = "index.html"; - this->recurse_ = 0; - this->debug_ = 0; - this->timeout_.sec (ACE_DEFAULT_TIMEOUT); - this->url_filter_ = 0; - this->verbose_ = 0; - this->order_ = "FIFO"; - this->port_no_ = ACE_DEFAULT_HTTP_PORT; - - // The default is to make this limit as large as possible. - this->handle_limit_ = -1; - - for (int c; - (c = getopt ()) != EOF; - ) - switch (c) - { - case 'd': - this->debug_ = 1; - break; - case 'f': - this->url_filter_ = getopt.optarg; - break; - case 'h': - this->hostname_ = getopt.optarg; - break; - case 'i': - this->uri_ = getopt.optarg; - break; - case 'l': - this->handle_limit_ = ACE_OS::atoi (getopt.optarg); - break; - case 'r': - this->recurse_ = 1; - break; - case 't': - this->timeout_.sec (ACE_OS::atoi (getopt.optarg)); - break; - case 'u': - { - this->hostname_ = getopt.optarg; - char *s = ACE_OS::strchr (getopt.optarg, '/'); - if (s != 0) - { - this->uri_ = s + 1; - *s = '\0'; - } - else - ACE_ERROR ((LM_ERROR, - "invalid URL %s\n", - getopt.optarg)); - } - break; - case 'v': - this->verbose_ = 1; - break; - case 'o': - { - this->order_ = getopt.optarg; - } - break; - case 'p': - this->port_no_ = ACE_OS::atoi (getopt.optarg); - break; - default: - ACE_ERROR ((LM_ERROR, - "usage: %n [-d] [-f filter] [-h hostname]" - " [-l handle-limit] [-r] [-t timeout] [-u URI]" - " [-v]\n%a", - 1)); - - /* NOTREACHED */ - } - - return 0; -} - -int -Options::port_no (void) const -{ - return this->port_no_; -} - -int -Options::recurse (void) const -{ - return this->recurse_; -} - -const ACE_Time_Value * -Options::timeout (void) const -{ - return &this->timeout_; -} - -int -Options::debug (void) const -{ - return this->debug_; -} - -int -Options::verbose (void) const -{ - return this->verbose_; -} - -LPCTSTR -Options::order (void) const -{ - return this->order_; -} -LPCTSTR -Options::hostname (void) const -{ - return this->hostname_; -} - -LPCTSTR -Options::path_name (void) const -{ - return this->uri_; -} - -LPCTSTR -Options::url_filter (void) const -{ - return this->url_filter_; -} - -Command_Processor * -Options::command_processor (void) const -{ - return this->command_processor_; -} - -void -Options::command_processor (Command_Processor *cp) -{ - this->command_processor_ = cp; -} - -URL_Visitor * -Options::visitor (void) const -{ - return this->visitor_; -} - -void -Options::visitor (URL_Visitor *v) -{ - this->visitor_ = v; -} - -int -Options::handle_limit (void) -{ - return this->handle_limit_; -} diff --git a/examples/Web_Crawler/Options.h b/examples/Web_Crawler/Options.h deleted file mode 100644 index e7f38b74d71..00000000000 --- a/examples/Web_Crawler/Options.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// Options.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _OPTIONS_H -#define _OPTIONS_H - -#include "ace/Singleton.h" -#include "ace/Synch.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Forward decls. -class Command_Processor; -class URL_Visitor; - -class Options -{ - // = TITLE - // Maintains the global options. - // - // = DESCRIPTION - // This class is converted into a Singleton by the - // <ACE_Singleton> template. -public: - int parse_args (int argc, char *argv[]); - // Parse the command-line arguments and initialize the options. - - int recurse (void) const; - // If non-0 and the link is an HTML file then recursively check all - // links that are embedded in the body of file. - - LPCTSTR hostname (void) const; - // Return the hostname of the initial Web server. - - LPCTSTR path_name (void) const; - // Return the initial URI. - - LPCTSTR url_filter (void) const; - // String used to filter out which URLs to validate. - - int debug (void) const; - // Are we debugging? - - int verbose (void) const; - // Are we being verbose? - - LPCTSTR order (void) const; - // Which order? LIFO|FIFO?? - - int port_no (void) const; - // Port # - - const ACE_Time_Value *timeout (void) const; - // Return the timeout used to prevent hanging on <recv> and - // <connect> calls to broken servers. - - // = Get/set the <Command_Processor>. - Command_Processor *command_processor (void) const; - void command_processor (Command_Processor *); - - // = Get/set the <URL_Visitor>. - URL_Visitor *visitor (void) const; - void visitor (URL_Visitor *); - - // Get the handle_limit. - int handle_limit (void); -private: - int recurse_; - // Are we recursving. - - LPCTSTR hostname_; - // Initial Web server name. - - LPCTSTR uri_; - // Initial URI name. - - int debug_; - // Are we debugging? - - int verbose_; - // Are we being verbose? - - LPCTSTR order_; - // Whether the URLs are traversed in FIFO or LIFO order. - - ACE_Time_Value timeout_; - // Timeout on <recv> and <connect> to broken Web servers. - - LPCTSTR url_filter_; - // String used to filter out which URLs to validate. - - Command_Processor *command_processor_; - // Pointer to the Command_Processor. - - URL_Visitor *visitor_; - // Pointer to the <URL_Visitor>. - - int port_no_; - // Port no. - - int handle_limit_; - // The limit of the number of descriptors to be given for this process. -}; - -// Typedef an Options Singleton. -typedef ACE_Singleton <Options, ACE_Null_Mutex> OPTIONS; - -#endif /* _OPTIONS_H */ diff --git a/examples/Web_Crawler/README b/examples/Web_Crawler/README deleted file mode 100644 index 4f81809173d..00000000000 --- a/examples/Web_Crawler/README +++ /dev/null @@ -1,25 +0,0 @@ -Web Crawler Kirthika Parameswaran ------------ - -The Web Crawler follows the HTTP_1.1 protocol. - -This Crawler crawls in either FIFO or LIFO order over the URLs -now stored in a ACE_Unbounded_Queue. The Command Processor pattern is -used in this example. - -Also the auto-purging feature where connections are removed from the cache -when the process runs out of file descriptors, is added to this example. - -[Use the -l option to set the handle limit]. - -Run: ---- - - -> make - -> main -r -u www.cs.wustl.edu/~kirthika/test.html -o LIFO - -or - -> main -r -u www.cs.wustl.edu/~kirthika/test.html -o FIFO diff --git a/examples/Web_Crawler/URL.cpp b/examples/Web_Crawler/URL.cpp deleted file mode 100644 index ce52ed892ad..00000000000 --- a/examples/Web_Crawler/URL.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// $Id$ - -#include "URL.h" - -ACE_RCSID(Web_Crawler, URL, "$Id$") - -Mem_Map_Stream & -URL::stream (void) -{ - return this->stream_; -} - -URL::~URL (void) -{ -} - -const URL_Status & -URL::reply_status (void) -{ - return this->reply_status_; -} - -void -URL::reply_status (const URL_Status &rs) -{ - this->reply_status_ = rs; -} - -const ACE_CString & -URL::content_type (void) -{ - return this->content_type_; -} - -void -URL::content_type (const ACE_CString &ct) -{ - this->content_type_ = ct; -} diff --git a/examples/Web_Crawler/URL.h b/examples/Web_Crawler/URL.h deleted file mode 100644 index 5b1df98be71..00000000000 --- a/examples/Web_Crawler/URL.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// URL.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _URL_H -#define _URL_H - -#include "Mem_Map_Stream.h" -#include "URL_Addr.h" -#include "URL_Status.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Forward declaration. -class URL_Visitor; - -class URL -{ - // = TITLE - // Base class for a URL. - // - // = DESCRIPTION - // This class plays a role in the Visitor pattern. -public: - virtual ~URL (void); - // Destructor. - - virtual int accept (URL_Visitor *visitor) = 0; - // Accept the visitor, which will then perform a particular - // visitation strategy on the URL. This method is part of the - // Visitor pattern. - - virtual int send_request (void) = 0; - // Send a <GET> command to fetch the contents in the URI from the - // server. - - virtual const ACE_URL_Addr &url_addr (void) const = 0; - // Returns the URL that we represent. - - virtual Mem_Map_Stream &stream (void); - // Returns the <Mem_Map_Stream>. - - // = Get/set the reply status. - virtual const URL_Status &reply_status (void); - virtual void reply_status (const URL_Status &); - - // = Get/set the reply status. - virtual const ACE_CString &content_type (void); - virtual void content_type (const ACE_CString &); - - - -private: - URL_Status reply_status_; - // Reply status of the URL. - - ACE_CString content_type_; - // Content-type of the URL. - - Mem_Map_Stream stream_; - // Contents of the stream. -}; - -#endif /* _URL_H */ diff --git a/examples/Web_Crawler/URL_Addr.cpp b/examples/Web_Crawler/URL_Addr.cpp deleted file mode 100644 index b60a2c54e06..00000000000 --- a/examples/Web_Crawler/URL_Addr.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// $Id$ -#include "URL_Addr.h" - -ACE_RCSID(Web_Crawler, URL_Addr, "$Id$") - -ACE_URL_Addr::ACE_URL_Addr (void) - : path_name_ (0), - addr_string_ (0), - addr_string_len_ (0) -{ -} - -int -ACE_URL_Addr::addr_to_string (LPTSTR s, - size_t size, - int ipaddr_format) const -{ - size_t total_len = - ACE_OS::strlen (ipaddr_format == 0 ? - this->get_host_name () : - this->get_host_addr ()) - + ACE_OS::strlen ("65536") // Assume the max port number. - + ACE_OS::strlen (this->get_path_name ()) - + sizeof (':') - + sizeof ('/') - + sizeof ('\0'); // For trailing '\0'. - - if (size < total_len) - return -1; - else - { - ACE_OS::sprintf (s, ASYS_TEXT ("%s:%d/%s"), - ASYS_WIDE_STRING (ipaddr_format == 0 - ? this->get_host_name () - : this->get_host_addr ()), - this->get_port_number (), - this->get_path_name ()); - return 0; - } -} - -LPCTSTR -ACE_URL_Addr::addr_to_string (int ipaddr_format) const -{ - ACE_URL_Addr *this_ptr = ACE_const_cast (ACE_URL_Addr *, - this); - - size_t size = - ACE_OS::strlen (ipaddr_format == 0 ? - this->get_host_name () : - this->get_host_addr ()) - + ACE_OS::strlen ("65536") // Assume the max port number. - + ACE_OS::strlen (this->get_path_name ()) - + sizeof (':') - + sizeof ('/') - + sizeof ('\0'); // For trailing '\0'. - - if (size > this->addr_string_len_) - { - ACE_ALLOCATOR_RETURN (this_ptr->addr_string_, - (LPTSTR) ACE_OS::realloc ((void *) this->addr_string_, - size), - 0); - this_ptr->addr_string_len_ = size; - } - ACE_OS::sprintf (this->addr_string_, - ASYS_TEXT ("%s:%d/%s"), - ASYS_WIDE_STRING (ipaddr_format == 0 - ? this->get_host_name () - : this->get_host_addr ()), - this->get_port_number (), - this->get_path_name ()); - return this->addr_string_; -} - -int -ACE_URL_Addr::string_to_addr (LPCTSTR s) -{ - int result; - LPTSTR t; - - // Need to make a duplicate since we'll be overwriting the string. - ACE_ALLOCATOR_RETURN (t, - ACE_OS::strdup (s), - -1); - - - // First split off the path_name. - - LPTSTR path_name = ACE_OS::strchr (t, '/'); - LPCTSTR name = "index.html"; - if (path_name != 0) - { - if (ACE_OS::strlen (path_name + 1) > 0) - name = path_name + 1; - - *path_name = '\0'; - } - - ACE_ALLOCATOR_RETURN (this->path_name_, - // Skip over '/' - ACE_OS::strdup (name), - -1); - - // Now handle the host address and port number. - LPTSTR port_number = ACE_OS::strchr (t, ':'); - - if (port_number == 0) - { - // Assume it's an ip-address or ip-number. - result = this->ACE_INET_Addr::set (ACE_DEFAULT_HTTP_PORT, - t); - } - else - { - *port_number = '\0'; - u_short port = (u_short) ACE_OS::atoi (port_number + 1); // Skip over ':' - result = this->ACE_INET_Addr::set (port, t); - } - - ACE_OS::free (ACE_MALLOC_T (t)); - return result; -} - -ACE_URL_Addr::ACE_URL_Addr (const ACE_URL_Addr &addr) - : path_name_ (0), - addr_string_ (0), - addr_string_len_ (0) -{ - if (this->set (addr) == -1) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("%p\n"), - ASYS_TEXT ("ACE_URL_Addr::ACE_URL_Addr"))); -} - -int -ACE_URL_Addr::set (const ACE_URL_Addr &addr) -{ - ACE_OS::free (ACE_reinterpret_cast (void *, - ACE_const_cast (char *, - this->path_name_))); - ACE_OS::free (ACE_reinterpret_cast (void *, - ACE_const_cast (char *, - this->addr_string_))); - if (this->ACE_INET_Addr::set (addr) == -1) - return -1; - else - { - if (addr.path_name_) - ACE_ALLOCATOR_RETURN (this->path_name_, - ACE_OS::strdup (addr.path_name_), - -1); - if (addr.addr_string_) - ACE_ALLOCATOR_RETURN (this->addr_string_, - ACE_OS::strdup (addr.addr_string_), - -1); - this->addr_string_len_ = - addr.addr_string_len_; - return 0; - } -} - -void -ACE_URL_Addr::operator= (const ACE_URL_Addr &addr) -{ - if (this->set (addr) == -1) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("%p\n"), - ASYS_TEXT ("ACE_URL_Addr::ACE_URL_Addr"))); -} - -u_long -ACE_URL_Addr::hash (void) const -{ - u_long result = this->ACE_INET_Addr::hash () - + ACE::hash_pjw (this->get_path_name ()); - - return result; -} - -int -ACE_URL_Addr::operator== (const ACE_URL_Addr &addr) const -{ - return ACE_OS::strcmp (addr.get_path_name (), - this->get_path_name ()) == 0 - && addr.get_port_number () == this->get_port_number () - && addr.get_ip_address () == this->get_ip_address (); -} - -int -ACE_URL_Addr::operator!= (const ACE_URL_Addr &addr) const -{ - return !(*this == addr); -} - -ACE_URL_Addr::ACE_URL_Addr (LPCTSTR host_name, - LPCTSTR path_name, - u_short port) - : ACE_INET_Addr (port, host_name), - path_name_ (ACE_OS::strdup (path_name)), - addr_string_ (0), - addr_string_len_ (0) -{ -} - -LPCTSTR -ACE_URL_Addr::get_path_name (void) const -{ - return this->path_name_; -} - -ACE_URL_Addr::~ACE_URL_Addr (void) -{ - ACE_OS::free (ACE_reinterpret_cast (void *, - ACE_const_cast (LPTSTR, - this->path_name_))); - ACE_OS::free (ACE_reinterpret_cast (void *, - ACE_const_cast (LPTSTR, - this->addr_string_))); - this->path_name_ = 0; -} - -int -ACE_URL_Addr::destroy (void) -{ - // Commit suicide. - delete this; - return 0; -} diff --git a/examples/Web_Crawler/URL_Addr.h b/examples/Web_Crawler/URL_Addr.h deleted file mode 100644 index 823d95f1cc8..00000000000 --- a/examples/Web_Crawler/URL_Addr.h +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// URL_Addr.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef ACE_URL_ADDR_H -#define ACE_URL_ADDR_H - -#include "ace/INET_Addr.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -class ACE_URL_Addr : public ACE_INET_Addr -{ - // = TITLE - // Defines a URL address family address format. -public: - // = Initialization and termination methods. - ACE_URL_Addr (void); - // Constructor. - - ACE_URL_Addr (LPCTSTR host_name, - LPCTSTR path_name, - u_short port = ACE_DEFAULT_HTTP_PORT); - - ACE_URL_Addr (const ACE_URL_Addr &addr); - // Copy constructor. - - int set (const ACE_URL_Addr &addr); - // Essentially the copy constructor. - - virtual int string_to_addr (LPCTSTR address); - // Initializes an <ACE_URL_Addr> from the <address>, which can be - // "ip-number:port-number/path-name" (e.g., - // "www.cs.wustl.edu:1234/~schmidt/" "ip-number:port-number/path-name" - // (e.g., "128.252.166.57:1234/~schmidt"). If there is no ':' in - // the <address> it is assumed to be an ip-number or ip-address - // number, with the port number <ACE_DEFAULT_HTTP_PORT>. - - virtual int addr_to_string (LPTSTR s, - size_t size, - int ipaddr_format = 1) const; - // Transform the current <ACE_INET_Addr> address into string format. - // If <ipaddr_format> is non-0 this produces - // "ip-number:port-number/path-name" (e.g., - // "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 - // this produces "ip-name:port-number" (e.g., - // "www.cs.wustl.edu:80/~schmidt/"). Returns -1 if the <size> of - // the <buffer> is too small, else 0. - - virtual LPCTSTR addr_to_string (int ipaddr_format = 1) const; - // Transform the current <ACE_INET_Addr> address into string format. - // If <ipaddr_format> is non-0 this produces - // "ip-number:port-number/path-name" (e.g., - // "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 - // this produces "ip-name:port-number" (e.g., - // "www.cs.wustl.edu:80/~schmidt/"). Uses dynamic memory, which - // is allocated on demand and deallocated when the object is - // destroyed. Returns -1 if dynamic memory fails, else 0. - - void operator= (const ACE_URL_Addr &addr); - // Assignment operator. - - ~ACE_URL_Addr (void); - // Destructor. - - int operator == (const ACE_URL_Addr &SAP) const; - // Compare two addresses for equality. The addresses are considered - // equal if they contain the same IP address, port number, and path - // name. - - int operator != (const ACE_URL_Addr &SAP) const; - // Compare two addresses for inequality. - - virtual u_long hash (void) const; - // Computes and returns hash value. - - LPCTSTR get_path_name (void) const; - // Return the path name. - - int destroy (void); - // Commit suicide. -private: - LPTSTR path_name_; - // Our path name. - - LPTSTR addr_string_; - // The dynamically address string that's used for the - // <addr_to_string> method. - - size_t addr_string_len_; - // Current length of the <addr_string_> -}; - -#endif /* ACE_URL_ADDR_H */ diff --git a/examples/Web_Crawler/URL_Status.cpp b/examples/Web_Crawler/URL_Status.cpp deleted file mode 100644 index 35a57420593..00000000000 --- a/examples/Web_Crawler/URL_Status.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "URL_Status.h" - -ACE_RCSID(Web_Crawler, URL_Status, "$Id$") - -URL_Status::URL_Status (STATUS_CODE code) - : status_ (code) -{ -} - -URL_Status::URL_Status (const URL_Status &s) - : status_ (s.status_) -{ -} - -URL_Status::STATUS_CODE -URL_Status::status (void) const -{ - return this->status_; -} - -void -URL_Status::status (int s) -{ - this->status_ = URL_Status::STATUS_CODE (s); -} - -void -URL_Status::status (URL_Status::STATUS_CODE s) -{ - this->status_ = s; -} - -int URL_Status::destroy (void) -{ - delete this; - return 0; -} diff --git a/examples/Web_Crawler/URL_Status.h b/examples/Web_Crawler/URL_Status.h deleted file mode 100644 index fa8186d6e9a..00000000000 --- a/examples/Web_Crawler/URL_Status.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// URL_Status.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _URL_STATUS_H -#define _URL_STATUS_H - -#include "ace/OS.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -class URL_Status -{ - // = TITLE -public: - enum STATUS_CODE - { - STATUS_OK = 200, - STATUS_CREATED = 201, - STATUS_ACCEPTED = 202, - STATUS_NO_CONTENT = 204, - STATUS_MOVED_PERMANENTLY = 301, - STATUS_MOVED_TEMPORARILY = 302, - STATUS_NOT_MODIFIED = 304, - STATUS_BAD_REQUEST = 400, - STATUS_UNAUTHORIZED = 401, - STATUS_FORBIDDEN = 403, - STATUS_NOT_FOUND = 404, - STATUS_INTERNAL_SERVER_ERROR = 500, - STATUS_NOT_IMPLEMENTED = 501, - STATUS_BAD_GATEWAY = 502, - STATUS_SERVICE_UNAVAILABLE = 503, - STATUS_INSUFFICIENT_DATA = 399 - }; - - URL_Status (STATUS_CODE = STATUS_INSUFFICIENT_DATA); - URL_Status (const URL_Status &); - - STATUS_CODE status (void) const; - void status (int); - void status (STATUS_CODE); - int destroy (void); -private: - STATUS_CODE status_; -}; - -#endif /* _URL_STATUS_H */ diff --git a/examples/Web_Crawler/URL_Visitor.cpp b/examples/Web_Crawler/URL_Visitor.cpp deleted file mode 100644 index c2a3f9b0701..00000000000 --- a/examples/Web_Crawler/URL_Visitor.cpp +++ /dev/null @@ -1,604 +0,0 @@ -// $Id$ - -#include "URL_Visitor.h" -#include "Command_Processor.h" - -ACE_RCSID(Web_Crawler, URL_Visitor, "$Id$") - -URL_Processing_Strategy::URL_Processing_Strategy (URL &url, - URL_Iterator &iterator) - : url_ (url), - iterator_ (iterator) -{ -} - -int -URL_Processing_Strategy::destroy (void) -{ - // Commit suicide. - delete this; - return 0; -} - -URL_Download_Strategy::URL_Download_Strategy (URL &url, - URL_Iterator &iterator) - : URL_Processing_Strategy (url, iterator) -{ -} - -int -URL_Download_Strategy::execute (void) -{ - ACE_CString buffer; - - // Extract all the contents of the Stream and print them to the - // file. - while (this->iterator_.next (buffer) != 0) - ACE_DEBUG ((LM_DEBUG, - "%s", - buffer.c_str ())); - - return 0; -} - -HTTP_Header_Processing_Strategy::HTTP_Header_Processing_Strategy (URL &url, - URL_Iterator &iterator) - : URL_Processing_Strategy (url, iterator) -{ -} - -int -HTTP_Header_Processing_Strategy::execute (void) -{ - ACE_DEBUG ((LM_DEBUG, "HEADER\n")); - // Set the get() position.Necessary since later a peek is done. - if (this->url_.stream ().get_char () == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n","Header Not Found"), - -1); - char line_buf[BUFSIZ + 1]; - ACE_CString line (line_buf); - // Get the lines in the header iteratively and check for status info. - int result = 1, i = 0; - for (i = 0, result = this->iterator_.next (line); - result > 0; - ++i, result = this->iterator_.next (line)) - { - if (i == 0) - { - ACE_DEBUG ((LM_DEBUG, "LINE:%s", line.c_str ())); - // Assuming that the status-no is a space away. - int status_index = line.find ("HTTP", 0); - ACE_CString status = line.substring (status_index + 9, //HTTP/1.1 200 - 3); - // DONE ONLY FOR TEMP USE AS OF NOW THE HTTP_SERVER DOESNT SEND AN HEADER. - // ACE_CString status_buf ("200"); - // status.set (status_buf.c_str (), 1); - - ACE_DEBUG ((LM_DEBUG, "STATUS %s\n", status.c_str ())); - URL_Status *url_status = 0; - ACE_NEW_RETURN (url_status, - URL_Status, - 0); - Auto_Destroyer<URL_Status> url_status_ptr (url_status); - url_status_ptr->status (ACE_OS::atoi (status.c_str ())); - this->url_.reply_status (**url_status_ptr); - // Invalid url. - if (url_status_ptr->status () != 200) - return -1; - } - else - { - - if (line.find ("text/html") >= 0) - { - ACE_CString url_content_type("text/html"); - this->url_.content_type (url_content_type); - } - } - } - return 0; - -} - -HTML_Body_Validation_Strategy::HTML_Body_Validation_Strategy (URL &url, - URL_Iterator &iterator, - URL_Validation_Visitor &context) - : URL_Processing_Strategy (url, iterator), - visitor_context_ (context) -{ -} - -int -HTML_Body_Validation_Strategy::execute (void) -{ - char host_name_buf[BUFSIZ + 1]; - ACE_CString host_name (host_name_buf); - host_name.set (url_.url_addr ().get_host_name (),1); - - // All to facilitate relative paths - char temp[BUFSIZ + 1]; - ACE_CString prev_location (temp); - - prev_location.set (this->url_.url_addr ().get_path_name (), - ACE_OS::strlen (this->url_.url_addr ().get_path_name ()), - 1); - int index = prev_location.rfind ('/', prev_location.length ()); - ACE_CString str = prev_location.substring (0, index + 1); - prev_location.set (str.c_str (), 1); - - // Note: prev_location always ends with '/' - if (prev_location[0] != '/') - prev_location = "/" + prev_location; - - // Build the url portion which can be attached to teh relative paths. - prev_location = host_name + prev_location; - - char url_string[BUFSIZ + 1]; - ACE_CString url (url_string); - - while (this->iterator_.next (url) > 0) - { - // Check for relative urls.Strip out "http://" if its there. - if (url.find ("http") < 0) - { - if (url[0] == '.' && url[1] == '.') - { - url.set (&url[3], 1); - int i = prev_location.rfind ('/', prev_location.length () - 1); - prev_location = prev_location.substring (0, i+1); - } - if (url[0] == '.' && url[1] == '/') - url.set (&url[2], 1); - - url = prev_location + url; - } - else - url.set (&url[7], 1); - // Double slash at the end works!e.g www.cs.wustl.edu/~kirthika// - if (url.find (".html") < 0) - url = url + "/"; - - // Create the new URL address. - ACE_URL_Addr *url_addr; - ACE_NEW_RETURN (url_addr, - ACE_URL_Addr, - 0); - Auto_Destroyer<ACE_URL_Addr> url_addr_ptr (url_addr); - if (url_addr_ptr->string_to_addr (url.c_str ()) == 0) - { - HTTP_URL *http_url; - ACE_NEW_RETURN (http_url, - HTTP_URL (**url_addr_ptr, - ACE_dynamic_cast (HTTP_URL *, - &this->url_)), - 0); - URL_Command *url_command; - ACE_NEW_RETURN (url_command, - URL_Command (http_url), - 0); - - OPTIONS::instance ()->command_processor ()->insert (url_command); - } - } - return 0; -} - -URL_Iterator * -URL_Validation_Visitation_Strategy_Factory::make_header_iterator (void) -{ - URL_Iterator *i; - ACE_NEW_RETURN (i, - HTTP_Header_Iterator (*this->url_), - 0); - return i; -} - -URL_Iterator * -URL_Validation_Visitation_Strategy_Factory::make_body_iterator (void) -{ - URL_Iterator *i; - ACE_NEW_RETURN (i, - HTML_Body_Iterator (*this->url_), - 0); - return i; -} - -URL_Processing_Strategy * -URL_Validation_Visitation_Strategy_Factory::make_header_strategy (URL_Iterator &iterator) -{ - URL_Processing_Strategy *ps; - ACE_NEW_RETURN (ps, - HTTP_Header_Processing_Strategy (*this->url_, - iterator), - 0); - return ps; -} - -URL_Processing_Strategy * -URL_Validation_Visitation_Strategy_Factory::make_body_strategy (URL_Iterator &iterator) -{ - URL_Processing_Strategy *ps; - ACE_NEW_RETURN (ps, - HTML_Body_Validation_Strategy (*this->url_, - iterator, - this->visitor_context_), - 0); - return ps; -} - -int -URL_Validation_Visitation_Strategy_Factory::destroy (void) -{ - // Commit suicide. - delete this; - return 0; -} - -URL_Validation_Visitor::URL_Validation_Visitor (void) -{ - ACE_DEBUG ((LM_DEBUG, "URL_Validation_Visitor_Factory::Strategy Con created\n")); - ACE_NEW (this->strat_connector_, - STRAT_CONNECTOR(0, - &creation_strategy_, - &caching_connect_strategy_, - &activation_strategy_)); - if (strat_connector_ == 0) - ACE_ERROR ((LM_ERROR, - "%p %s\n" - "strategy connector creation failed")); - - -} - -URL_Validation_Visitor::~URL_Validation_Visitor (void) -{ -} - -URL_Validation_Visitor::URL_CACHE & -URL_Validation_Visitor::url_cache (void) -{ - return this->url_cache_; -} - -int -URL_Validation_Visitor::in_cache (const ACE_URL_Addr &url_addr) -{ - URL_Status reply_status (URL_Status::STATUS_CODE (1)); - - if (this->url_cache_.find (url_addr, reply_status) == 0) - { - ACE_DEBUG ((LM_DEBUG, - "status %d for URL %s (cached)\n", - reply_status.status (), - url_addr.addr_to_string (0))); - - // Invalid status. - if (reply_status.status () != 200) - return -1; - - return 1; - } - else - return 0; -} - -URL_Visitation_Strategy_Factory * -URL_Validation_Visitor::make_visitation_strategy_factory (URL &url) -{ - // Since this is HTTP 1.1 we'll need to establish a connection - // only once. Trying for relative paths. - // if (this->url_addr ().get_hostname () != url_hostname) - // { - if (url.stream ().open (this->strat_connector_, - url.url_addr ()) == -1) - return 0; - // } - // See if we can get connected and send the GET request via the - // <HTTP_URL>. - int result = url.send_request (); - if (result == -1) - { - ACE_ERROR ((LM_ERROR, - "%p\n", - "send_request")); - if (this->url_cache_.bind (url.url_addr (), - URL_Status (URL_Status::STATUS_SERVICE_UNAVAILABLE)) == -1) - ACE_ERROR ((LM_ERROR, - "%p\n", - "bind")); - return 0; - } - // @@ Here's where we could check to see if the <url> was HTTP or - // FTP, etc. But for now we'll just assume that everything is an - // HTTP URL. - else - { - - URL_Visitation_Strategy_Factory *vs; - ACE_NEW_RETURN (vs, - URL_Validation_Visitation_Strategy_Factory (&url, - *this), - 0); - return vs; - } -} - -int -URL_Validation_Visitor::destroy (void) -{ - delete this->strat_connector_; - // Commit suicide. - delete this; - return 0; -} - -int -URL_Validation_Visitor::visit (HTTP_URL &http_url) -{ - int result = this->in_cache (http_url.url_addr ()); - /* if (result == -1) - { - ACE_DEBUG ((LM_DEBUG, - "Invalid URL:%s (cached)\n", - http_url.url_addr().addr_to_string (0))); - return 0; - }*/ - if (result == 0) - { - Auto_Destroyer <URL_Visitation_Strategy_Factory> vs (this->make_visitation_strategy_factory (http_url)); - - if (*vs == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_visitation_strategy_factory"), - -1); - - Auto_Destroyer <URL_Iterator> ihs (vs->make_header_iterator ()); - if (*ihs == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_header_iterator"), - -1); - Auto_Destroyer <URL_Processing_Strategy> phs (vs->make_header_strategy (**ihs)); - if (*phs == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_header_strategy"), - -1); - int phs_result = phs->execute (); - if (phs_result == -1) - ACE_DEBUG ((LM_DEBUG, - "Invalid ")); - - ACE_DEBUG ((LM_DEBUG, - "URL with status %d %s\n", - http_url.reply_status ().status (), - http_url.url_addr().addr_to_string (0))); - - // Store the http url in the cache. - if (this->url_cache ().bind (http_url.url_addr (), - http_url.reply_status ()) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n","url_cache.bind"), - -1); - - // ACE_DEBUG ((LM_DEBUG, "header_processing result %d\n", phs_result)); - // Since it is invalid dont go further. - if (phs_result == -1) - return 0; - - // Get back if the recurse option isnt set. - if (OPTIONS::instance ()->recurse () != 1) - return 0; - - Auto_Destroyer <URL_Iterator> is (vs->make_body_iterator ()); - if (*is == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_body_iterator"), - -1); - - Auto_Destroyer <URL_Processing_Strategy> ps (vs->make_body_strategy (**is)); - if (*ps == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_body_strategy"), - -1); - - if (ps->execute () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "body execute"), - -1); - // http_url.stream().svc_handler ()->idle ();//KIRTHIKA - } - return 0; -} - -int -URL_Download_Visitation_Strategy_Factory::destroy (void) -{ - // Commit suicide. - delete this; - return 0; -} - -URL_Iterator * -URL_Download_Visitation_Strategy_Factory::make_header_iterator (void) -{ - return 0; -} - -URL_Iterator * -URL_Download_Visitation_Strategy_Factory::make_body_iterator (void) -{ - URL_Iterator *i; - ACE_NEW_RETURN (i, - URL_Download_Iterator (*this->url_), - 0); - return i; -} - -URL_Processing_Strategy * -URL_Download_Visitation_Strategy_Factory::make_header_strategy (URL_Iterator &iterator) -{ - // You fill in here. - return 0; -} - -URL_Processing_Strategy * -URL_Download_Visitation_Strategy_Factory::make_body_strategy (URL_Iterator &iterator) -{ - URL_Processing_Strategy *ps; - ACE_NEW_RETURN (ps, - URL_Download_Strategy (*this->url_, - iterator), - 0); - return ps; -} - -URL_Visitation_Strategy_Factory::URL_Visitation_Strategy_Factory (URL *url) - : url_ (url) -{ -} - -URL_Download_Visitation_Strategy_Factory::URL_Download_Visitation_Strategy_Factory (URL *url) - : URL_Visitation_Strategy_Factory (url) -{ -} - -URL_Validation_Visitation_Strategy_Factory::URL_Validation_Visitation_Strategy_Factory (URL *url, - URL_Validation_Visitor &visitor_context) - : URL_Visitation_Strategy_Factory (url), - visitor_context_ (visitor_context) -{ -} - -URL_Visitation_Strategy_Factory * -URL_Download_Visitor::make_visitation_strategy_factory (URL &url) -{ - // See if we can get connected and send the GET request via the - // <HTTP_URL>. - while (1) //KIRTHIKA - { - int retval = url.send_request (); - if (retval != -1) - break; - - /* ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "send_request"), - 0);*/ - } - // @@ Here's where we could check to see if the <url> was HTTP or - // FTP, etc. But for now we'll just assume that everything is an - // HTTP URL. - // else - // { - URL_Visitation_Strategy_Factory *vs; - ACE_NEW_RETURN (vs, - URL_Download_Visitation_Strategy_Factory (&url), - 0); - return vs; - // } -} - -int -URL_Download_Visitor::destroy (void) -{ - // Commit suicide. - delete this; - return 0; -} - -int -URL_Download_Visitor::visit (HTTP_URL &http_url) -{ - Auto_Destroyer <URL_Visitation_Strategy_Factory> vs (this->make_visitation_strategy_factory (http_url)); - - if (*vs == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_visitation_strategy_factory"), - -1); - - Auto_Destroyer <URL_Iterator> is (vs->make_body_iterator ()); - if (*is == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_body_iterator"), - -1); - - Auto_Destroyer <URL_Processing_Strategy> ps (vs->make_body_strategy (**is)); - if (*ps == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_body_strategy"), - -1); - - if (ps->execute () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "body execute"), - -1); - return 0; -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Hash_Map_Manager<ACE_URL_Addr, URL_Status, ACE_Null_Mutex>; -template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; -template class ACE_Strategy_Connector<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>, ACE_SOCK_CONNECTOR>; -template class ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>; -template class ACE_NOOP_Creation_Strategy<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> >; -template class ACE_NOOP_Concurrency_Strategy<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> >; -template class ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex>; -template class ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> >; -template class ACE_Cached_Connect_Strategy_Ex<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>,ACE_SOCK_CONNECTOR, ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> >, ACE_SYNCH_NULL_MUTEX >; -template class ACE_Creation_Strategy<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> >; -template class ACE_Concurrency_Strategy<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> >; -template class ACE_Hash_Map_Manager_Ex<ACE_URL_Addr, URL_Status, ACE_Hash<ACE_URL_Addr>, ACE_Equal_To<ACE_URL_Addr>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>, ACE_Pair<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> *, int> >; -template class ACE_Connect_Strategy<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH>, ACE_SOCK_Connector>; -template class ACE_Hash_Map_Iterator_Base_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>, ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> *, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex>; -template class ACE_Optimal_Cache_Map_Manager<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> > >; -template class ACE_Optimal_Cache_Map_Reverse_Iterator<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> > >; -template class ACE_Optimal_Cache_Map_Iterator<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> > >; -template class ACE_Hash_Map_Entry<ACE_URL_Addr, URL_Status>; -template class ACE_Hash_Map_Iterator_Base_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>, ACE_Pair<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex>; -template class ACE_Recycling_Strategy<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> > ; -template class ACE_Connector<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH>, ACE_SOCK_Connector>; -template class ACE_Map_Manager<int, ACE_Svc_Tuple<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> > *, ACE_RW_Thread_Mutex>; -template class ACE_Svc_Tuple<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> >; -template class ACE_Hash_Map_Iterator_Base_Ex<ACE_URL_Addr, URL_Status, ACE_Hash<ACE_URL_Addr>, ACE_Equal_To<ACE_URL_Addr>, ACE_Null_Mutex>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Hash_Map_Manager<ACE_URL_Addr, URL_Status, ACE_Null_Mutex> -#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> -#pragma instantiate ACE_Strategy_Connector<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>, ACE_SOCK_CONNECTOR> -#pragma instantiate ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> -#pragma instantiate ACE_NOOP_Creation_Strategy<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> > -#pragma instantiate ACE_NOOP_Concurrency_Strategy<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> > -#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *,int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> -#pragma instantiate ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> > -#pragma instantiate ACE_Cached_Connect_Strategy_Ex<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>,ACE_SOCK_CONNECTOR, ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> >, ACE_SYNCH_NULL_MUTEX > -#pragma instantiate ACE_Creation_Strategy<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> >; -#pragma instantiate ACE_Concurrency_Strategy<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> >; -#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_URL_Addr, URL_Status, ACE_Hash<ACE_URL_Addr>, ACE_Equal_To<ACE_URL_Addr>, ACE_Null_Mutex>; -#pragma instantiate ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>, ACE_Pair<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> *, int> >; -#pragma instantiate ACE_Connect_Strategy<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH>, ACE_SOCK_Connector>; -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>, ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> *, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex>; -#pragma instantiate ACE_Optimal_Cache_Map_Manager<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> > > -#pragma instantiate ACE_Optimal_Cache_Map_Reverse_Iterator<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> > > -#pragma instantiate ACE_Optimal_Cache_Map_Iterator<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_LRU_Caching_Strategy<ACE_Hash_Map_Manager_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>,ACE_Pair<ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> > > -#pragma instantiate ACE_Hash_Map_Entry<ACE_URL_Addr, URL_Status> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>, ACE_Pair<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> *, int>, ACE_Hash<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Equal_To<ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> >, ACE_Null_Mutex> -#pragma instantiate ACE_Recycling_Strategy<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> > -#pragma instantiate ACE_Connector<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH>, ACE_SOCK_Connector> -#pragma instantiate ACE_Map_Manager<int, ACE_Svc_Tuple<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> > *, ACE_RW_Thread_Mutex> -#pragma instantiate ACE_Svc_Tuple<ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> > -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_URL_Addr, URL_Status, ACE_Hash<ACE_URL_Addr>, ACE_Equal_To<ACE_URL_Addr>, ACE_Null_Mutex> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/examples/Web_Crawler/URL_Visitor.h b/examples/Web_Crawler/URL_Visitor.h deleted file mode 100644 index 2ce1d6ec78c..00000000000 --- a/examples/Web_Crawler/URL_Visitor.h +++ /dev/null @@ -1,372 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// URL_Visitor.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _URL_VISITOR_H -#define _URL_VISITOR_H - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Strategies_T.h" -#include "ace/Synch.h" -#include "ace/Hash_Map_Manager.h" -#include "HTTP_URL.h" -#include "Iterators.h" -#include "ace/Hash_Map_Manager_T.h" -#include "Caching_Strategies_T.h" -#include "Cached_Connect_Strategy_T.h" -#include "Options.h" - -// Forward declarations. -class URL_Validation_Visitor; - -class URL_Processing_Strategy -{ - // = TITLE - // Abstract base class for the URL processing strategy. - // - // = DESCRIPTION -public: - URL_Processing_Strategy (URL &, - URL_Iterator &); - // Constructor. - - virtual int execute (void) = 0; - // Perform the strategy. - - virtual int destroy (void); - // Close down the resources. - -protected: - URL &url_; - // A reference to the URL "context" that we're processing. - - URL_Iterator &iterator_; - // Iterator for the URL that we're processing. -}; - -class HTTP_Header_Processing_Strategy : public URL_Processing_Strategy -{ - // = TITLE - // Defines the HTTP header processing strategy. - // - // = DESCRIPTION -public: - HTTP_Header_Processing_Strategy (URL &, - URL_Iterator &); - // Constructor. - - virtual int execute (void); - // Perform the strategy for processing an HTTP header. -}; - -class HTML_Body_Validation_Strategy : public URL_Processing_Strategy -{ - // = TITLE - // Defines the HTML body processing strategy. - // - // = DESCRIPTION - // This class iterates through the body of an HTML file and - // recursively visits embedded links. -public: - HTML_Body_Validation_Strategy (URL &, - URL_Iterator &, - URL_Validation_Visitor &); - // Constructor. - - virtual int execute (void); - // Perform the strategy for processing an HTML file. This strategy - // iterates over the HTML file and recursively visits embedded links - // to process them, as well. - -private: - URL_Validation_Visitor &visitor_context_; - // This is the context of the visit. -}; - -class URL_Download_Strategy : public URL_Processing_Strategy -{ - // = TITLE - // Defines a URL downloading strategy. - // - // = DESCRIPTION - // This class downloads a URL's contents into a temporary file. -public: - URL_Download_Strategy (URL &, - URL_Iterator &); - // Constructor. - - virtual int execute (void); - // Perform the strategy for downloading a URL to a temporary file. -}; - -class URL_Visitation_Strategy_Factory -{ - // = TITLE - // Abstract Factory for the URL visitation strategy. - // - // = DESCRIPTION -public: - URL_Visitation_Strategy_Factory (URL *); - - // = Factory Methods. - virtual URL_Iterator *make_header_iterator (void) = 0; - // Factory Method that makes the header iterator. - - virtual URL_Iterator *make_body_iterator (void) = 0; - // Factory Method that makes the body iterator. - - virtual URL_Processing_Strategy *make_header_strategy (URL_Iterator &) = 0; - // Factory Method that makes the header processing strategy. - - virtual URL_Processing_Strategy *make_body_strategy (URL_Iterator &) = 0; - // Factory Method that makes the body processing strategy . - - virtual int destroy (void) = 0; - // Close down the resources. - -protected: - URL *url_; - // Stash the URL so we don't have to pass it around. -}; - -class URL_Download_Visitation_Strategy_Factory : public URL_Visitation_Strategy_Factory -{ - // = TITLE - // Concrete Factory for the URL validation visitation strategy. - // - // = DESCRIPTION -public: - URL_Download_Visitation_Strategy_Factory (URL *); - // Constructor. - - // = Factory Methods. - virtual URL_Iterator *make_header_iterator (void); - // Factory Method that makes an <HTTP_Header_Iterator>. - - virtual URL_Iterator *make_body_iterator (void); - // Factory Method that makes an <HTML_Body_Iterator>. - - virtual URL_Processing_Strategy *make_header_strategy (URL_Iterator &); - // Factory Method that makes the header processing strategy. - - virtual URL_Processing_Strategy *make_body_strategy (URL_Iterator &); - // Factory Method that makes the body processing strategy . - - virtual int destroy (void); - // Close down the resources. -}; - -class URL_Validation_Visitation_Strategy_Factory : public URL_Visitation_Strategy_Factory -{ - // = TITLE - // Concrete Factory for the URL validation visitation strategy. - // - // = DESCRIPTION -public: - URL_Validation_Visitation_Strategy_Factory (URL *, - URL_Validation_Visitor &); - // Constructor. - - // = Factory Methods. - virtual URL_Iterator *make_header_iterator (void); - // Factory Method that makes an <HTTP_Header_Iterator>. - - virtual URL_Iterator *make_body_iterator (void); - // Factory Method that makes an <HTML_Body_Iterator>. - - virtual URL_Processing_Strategy *make_header_strategy (URL_Iterator &); - // Factory Method that makes the header processing strategy. - - virtual URL_Processing_Strategy *make_body_strategy (URL_Iterator &); - // Factory Method that makes the body processing strategy . - - virtual int destroy (void); - // Close down the resources. - -private: - URL_Validation_Visitor &visitor_context_; - // Context of the visitor. -}; - -class URL_Visitor -{ - // = TITLE - // Base class for the URL Visitor. - // - // = DESCRIPTION - // This class plays the "visitor" role in the Visitor pattern. -public: - virtual int visit (HTTP_URL &http_url) = 0; - // Visit an <HTTP_URL>. - - // @@ - // virtual int visit (FTP_URL &http_url) = 0; - - virtual int destroy (void) = 0; - // Cleanup the resources. - -protected: - virtual URL_Visitation_Strategy_Factory *make_visitation_strategy_factory (URL &) = 0; - // Make the appropriate <URL_Visitation_Strategy_Factory>. -}; - -class URL_Validation_Visitor : public URL_Visitor -{ - // = TITLE - // Subclass that defines the URL validation visitor. - // - // = DESCRIPTION - // This class checks to make sure that the <HTTP_URL> is valid. - // If the <HTTP_URL> is an <HTML> file, it can also be used to - // recursively check that all embedded links in this file are - // valid. -public: - typedef ACE_Hash_Map_Manager <ACE_URL_Addr, URL_Status, ACE_Null_Mutex> - URL_CACHE; - - virtual int visit (HTTP_URL &http_url); - // Visit an <HTTP_URL> to make sure that it's valid. If the content - // type of the <HTTP_URL> is "text/html" and the <recursion> option - // is enabled then <visit> recursively checks each link embedded in - // the HTML page. - - // @@ - // virtual int visit (FTP_URL &http_url); - - URL_Validation_Visitor (void); - virtual int destroy (void); - // Cleanup the resources. - - URL_CACHE &url_cache (void); - // Returns a reference to the URL cache. - - typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> Svc_Handler; - - typedef ACE_Strategy_Connector<Svc_Handler, - ACE_SOCK_CONNECTOR> - STRAT_CONNECTOR; - typedef ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> - REFCOUNTED_HASH_RECYCLABLE_ADDRESS; - typedef ACE_NOOP_Creation_Strategy<Svc_Handler> - NULL_CREATION_STRATEGY; - typedef ACE_NOOP_Concurrency_Strategy<Svc_Handler> - NULL_ACTIVATION_STRATEGY; - - typedef ACE_Hash_Map_Manager_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,\ - ACE_Pair<Svc_Handler *, int>,\ - ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, \ - ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,\ - ACE_Null_Mutex> - CONNECTION_HASH_MAP; - typedef ACE_Hash_Map_Iterator_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,\ - ACE_Pair<Svc_Handler *, int>,\ - ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, \ - ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,\ - ACE_Null_Mutex> - CONNECTION_HASH_MAP_ITERATOR; - typedef ACE_Hash_Map_Reverse_Iterator_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,\ - ACE_Pair<Svc_Handler *, int>,\ - ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, \ - ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,\ - ACE_Null_Mutex> - CONNECTION_HASH_MAP_REVERSE_ITERATOR; - typedef ACE_LRU_Caching_Strategy<CONNECTION_HASH_MAP> - LRU; - typedef ACE_Cached_Connect_Strategy_Ex<Svc_Handler,ACE_SOCK_CONNECTOR, LRU, ACE_SYNCH_NULL_MUTEX> - CACHED_CONNECT_STRATEGY; - -protected: - virtual ~URL_Validation_Visitor (void); - virtual URL_Visitation_Strategy_Factory *make_visitation_strategy_factory (URL &); - // Factory Method that makes a - // <URL_Validation_Visitation_Strategy_Factory>. - - URL_CACHE url_cache_; - // Cache the status of URLs we've already validated. - - int in_cache (const ACE_URL_Addr &url_addr); - // Check to see if the reply status of this <url_addr> is in the - // cache. Returns 1 if so, 0 if not. - - NULL_CREATION_STRATEGY creation_strategy_; - NULL_ACTIVATION_STRATEGY activation_strategy_; - - // Configure the Strategy Connector with a strategy that caches - // connection. - CACHED_CONNECT_STRATEGY caching_connect_strategy_; - - STRAT_CONNECTOR *strat_connector_; -}; - -class URL_Download_Visitor : public URL_Visitor -{ - // = TITLE - // Subclass for the URL validtion visitor. - // - // = DESCRIPTION - // This class checks to make sure that the <HTTP_URL> is valid. -public: - virtual int visit (HTTP_URL &http_url); - // Visit an <HTTP_URL> to make sure that it's valid. If the content - // type of the <HTTP_URL> is "text/html" and the <recursion> option - // is enabled then <visit> recursively checks each link embedded in - // the HTML page. - - // @@ - // virtual int visit (FTP_URL &http_url); - - virtual int destroy (void); - // Cleanup the resources. - -protected: - URL_Visitation_Strategy_Factory *make_visitation_strategy_factory (URL &); - // Factory Method that makes a <URL_Download_Visitation_Strategy_Factory>. -}; - -template <class T> -class Auto_Destroyer -{ - // = TITLE - // Simple class that ensures the <destroy> method is called on our - // <URL_*> objects when they go out of scope. - // - // = DESCRIPTION - // This class is similar to an auto_ptr<> and should be used to - // simplify blocks of code that must create/destroy pointers to - // various <URL_*> related strategies and iterators. -public: - Auto_Destroyer (T *t): t_ (t) {} - T *operator-> (void) { return this->t_; } - T *operator *(void) { return this->t_; } - void operator= (T *t) - { - if (this->t_ != 0) - this->t_->destroy (); - this->t_ = t; - } - ~Auto_Destroyer (void) - { - if (this->t_ != 0) - t_->destroy (); - } -private: - T *t_; -}; - - -#endif /* _URL_VISITOR_H */ diff --git a/examples/Web_Crawler/URL_Visitor_Factory.cpp b/examples/Web_Crawler/URL_Visitor_Factory.cpp deleted file mode 100644 index aaf30db0460..00000000000 --- a/examples/Web_Crawler/URL_Visitor_Factory.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "URL_Visitor_Factory.h" - -ACE_RCSID(Web_Crawler, URL_Visitor_Factory, "$Id$") - -URL_Visitor * -URL_Validation_Visitor_Factory::make_visitor (void) -{ - URL_Visitor *v; - - ACE_NEW_RETURN (v, - URL_Validation_Visitor, - 0); - - return v; -} - -Command_Processor * -URL_Validation_Visitor_Factory::make_command_processor (void) -{ - Command_Processor *cp; - - ACE_NEW_RETURN (cp, - Command_Processor, - 0); - return cp; -} - -URL_Visitor * -URL_Download_Visitor_Factory::make_visitor (void) -{ - URL_Visitor *v; - - ACE_NEW_RETURN (v, - URL_Download_Visitor, - 0); - return v; -} - -Command_Processor * -URL_Download_Visitor_Factory::make_command_processor (void) -{ - return 0; -} diff --git a/examples/Web_Crawler/URL_Visitor_Factory.h b/examples/Web_Crawler/URL_Visitor_Factory.h deleted file mode 100644 index f1fc27d5bd4..00000000000 --- a/examples/Web_Crawler/URL_Visitor_Factory.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// URL_Visitor_Factory.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _URL_VISITOR_FACTORY_H -#define _URL_VISITOR_FACTORY_H - -#include "URL_Visitor.h" -#include "Command_Processor.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -class URL_Visitor_Factory -{ - // = TITLE - // Abstract base class that creates URL visitors. - // - // = DESCRIPTION - // Subclasses define each of the Factory Methods to - // make the right objects, which all "vary" together. -public: - virtual URL_Visitor *make_visitor (void) = 0; - // Factory Method that makes the appropriate type of <URL_Visitor>. - - virtual Command_Processor *make_command_processor (void) = 0; - // Factory Method that makes the appropriate type of - // <Command_Processor>. -}; - -class URL_Validation_Visitor_Factory : public URL_Visitor_Factory -{ - // = TITLE - // Create a URL visitor that validates URL links. -public: - virtual URL_Visitor *make_visitor (void); - // Factory Method that makes a <URL_Validation_Visitor>. - - virtual Command_Processor *make_command_processor (void); - // Factory Method that makes a <FIFO_Command_Processor>. - - -}; - -class URL_Download_Visitor_Factory : public URL_Visitor_Factory -{ - // = TITLE - // Create a URL visitor that downloads URL links. -public: - virtual URL_Visitor *make_visitor (void); - // Factory Method that makes a <URL_Download_Visitor>. - - virtual Command_Processor *make_command_processor (void); - // Factory Method that makes a <FIFO_Command_Processor>. -}; - -#endif /* _URL_VISITOR_FACTORY_H */ diff --git a/examples/Web_Crawler/Web_Crawler.cpp b/examples/Web_Crawler/Web_Crawler.cpp deleted file mode 100644 index 2fae698be26..00000000000 --- a/examples/Web_Crawler/Web_Crawler.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// $Id$ - -#include "Options.h" -#include "URL_Visitor_Factory.h" -#include "Web_Crawler.h" - -ACE_RCSID(Web_Crawler, Web_Crawler, "$Id$") - -Web_Crawler::~Web_Crawler (void) -{ - delete this->url_visitor_factory_; -} - -Web_Crawler::Web_Crawler (void) - : url_visitor_factory_ (0) -{ -} - -int -Web_Crawler::open (int argc, char *argv[]) -{ - if (OPTIONS::instance ()->parse_args (argc, argv) == -1) - return -1; - // @@ Put the ACE_Service_Config::open() stuff here somewhere... - else - { - // For now just hardcode this to create "validation" visitors. - ACE_NEW_RETURN (this->url_visitor_factory_, - URL_Validation_Visitor_Factory, - -1); - return 0; - } -} - -int -Web_Crawler::run (void) -{ - // Make the appropriate <URL_Visitor>. - Auto_Destroyer<URL_Visitor> visitor (this->url_visitor_factory_->make_visitor ()); - - if (*visitor == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_visitor"), - -1); - - // Make the appropriate <Command_Processor>. - Auto_Destroyer<Command_Processor> cp (this->url_visitor_factory_->make_command_processor ()); - - if (*cp == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_command_processor"), - -1); - - // Set the <Command_Processor> in the <Options> to make it visible. - OPTIONS::instance ()->command_processor (*cp); - - // Set the <URL_Visitor> in the <Options> to make it visible. - OPTIONS::instance ()->visitor (*visitor); - - // @@ You fill in here... - ACE_URL_Addr *url_addr; - ACE_NEW_RETURN (url_addr, - ACE_URL_Addr (OPTIONS::instance()->hostname (), - OPTIONS::instance()->path_name (), - OPTIONS::instance()->port_no ()), //KIRTHIKA - 0); - Auto_Destroyer<ACE_URL_Addr> url_addr_ptr (url_addr); - - HTTP_URL *http_url; - ACE_NEW_RETURN (http_url, - HTTP_URL (**url_addr_ptr), - 0); - - Auto_Destroyer<HTTP_URL> http_url_ptr (http_url); - - URL_Command *url_command; - ACE_NEW_RETURN (url_command, - URL_Command (*http_url_ptr), - 0); - // Auto_Destroyer<URL_Command> url_command_ptr (url_command); - - if (cp->insert (url_command) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", "insert"), - -1); - - if (cp->execute () != 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", "execute"), - -1); - return 0; -} - diff --git a/examples/Web_Crawler/Web_Crawler.dsp b/examples/Web_Crawler/Web_Crawler.dsp deleted file mode 100644 index a85ee9099e9..00000000000 --- a/examples/Web_Crawler/Web_Crawler.dsp +++ /dev/null @@ -1,216 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Web_Crawler" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=Web_Crawler - 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 "Web_Crawler.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 "Web_Crawler.mak" CFG="Web_Crawler - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Web_Crawler - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "Web_Crawler - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "Web_Crawler - 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 /MD /W3 /GX /O2 /I "..\..\\" /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 ace.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\\"
-
-!ELSEIF "$(CFG)" == "Web_Crawler - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Web_Craw"
-# PROP BASE Intermediate_Dir "Web_Craw"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# 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 /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 "Web_Crawler - Win32 Release"
-# Name "Web_Crawler - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter ".cpp"
-# Begin Source File
-
-SOURCE=.\Command_Processor.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\HTTP_URL.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Iterators.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\main.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Mem_Map_Stream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Options.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL_Addr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL_Status.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL_Visitor.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL_Visitor_Factory.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Web_Crawler.cpp
-# End Source File
-# End Group
-# Begin Group "Include Files"
-
-# PROP Default_Filter ".h"
-# Begin Source File
-
-SOURCE=.\Cached_Connect_Strategy_T.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Caching_Strategies_T.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Command_Processor.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\HTTP_URL.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Iterators.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Mem_Map_Stream.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Optimal_Cache_Map_Manager_T.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Options.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL_Addr.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL_Status.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL_Visitor.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\URL_Visitor_Factory.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Web_Crawler.h
-# End Source File
-# End Group
-# Begin Group "Template Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Cached_Connect_Strategy_T.cpp
-# PROP Exclude_From_Build 1
-# End Source File
-# Begin Source File
-
-SOURCE=.\Caching_Strategies_T.cpp
-# PROP Exclude_From_Build 1
-# End Source File
-# Begin Source File
-
-SOURCE=.\Optimal_Cache_Map_Manager_T.cpp
-# PROP Exclude_From_Build 1
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/examples/Web_Crawler/Web_Crawler.dsw b/examples/Web_Crawler/Web_Crawler.dsw deleted file mode 100644 index 44f83f42c1c..00000000000 --- a/examples/Web_Crawler/Web_Crawler.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "Web_Crawler"=.\Web_Crawler.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/examples/Web_Crawler/Web_Crawler.h b/examples/Web_Crawler/Web_Crawler.h deleted file mode 100644 index e2590f986ca..00000000000 --- a/examples/Web_Crawler/Web_Crawler.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// Web_Crawler.h -// -// = AUTHOR -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#ifndef _WEB_CRAWLER_H -#define _WEB_CRAWLER_H - -#include "URL_Addr.h" -#include "HTTP_URL.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Forward declaration. -class URL_Visitor_Factory; - -class Web_Crawler -{ - // = TITLE - // An abstraction for a Web Crawler. - // - // = DESCRIPTION - // This class is a Facade that organizes the other classes in the - // solution, which include a factory that creates a visitor, - // which in turn embodies the appropriate visitation strategy. -public: - // = Initialization and termination methods. - Web_Crawler (void); - // Constructor. - - ~Web_Crawler (void); - // Destructor. - - int open (int argc, char *argv[]); - // Parses the command-line options and initializes the - // <URL_Visitor_Factory>. - - int run (void); - // Run the Web Crawler and carries out whatever visitation strategy - // is configured. Returns -1 on failure and 0 on success. - -private: - URL_Visitor_Factory *url_visitor_factory_; - // Pointer to a factory that creates visitors that explore URLs and - // perform various tasks. Subclasses of <URL_Visitor_Factory> - // determine what happens during a visitation. -}; - -#endif /* _WEB_CRAWLER_H */ diff --git a/examples/Web_Crawler/main.cpp b/examples/Web_Crawler/main.cpp deleted file mode 100644 index f16b407f007..00000000000 --- a/examples/Web_Crawler/main.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// apps/Web -// -// = FILENAME -// main.cpp -// -// = DESCRIPTION -// This program implements a Web crawler that can be configured to -// apply various strategies to URLs that it visits. -// -// = AUTHOR -// Doug Schmidt <schmidt@cs.wustl.edu> -// -// ============================================================================ - -#include "Web_Crawler.h" -#include "Options.h" -#include "ace/Signal.h" - -ACE_RCSID(Web_Crawler, main, "$Id$") - -void sig_handler (int) -{ - ACE_DEBUG ((LM_DEBUG, - "aborting!\n")); - ACE_OS::abort (); -} - -int -main (int argc, char *argv[]) -{ - ACE_Sig_Action sa ((ACE_SignalHandler) sig_handler, SIGFPE); - - Web_Crawler crawler; - - if (crawler.open (argc, argv) == -1) - return 1; - else if (crawler.run () == -1) - return 1; - else - return 0; -} - - - |
