int HTTP_Server::asynch_thread_pool (void) { // This only works on Win32 #if defined (ACE_WIN32) // Create the appropriate acceptor for this concurrency strategy and // an appropriate handler for this I/O strategy ACE_Asynch_Acceptor<Asynch_HTTP_Handler_Factory> acceptor; // Tell the acceptor to listen on this->port_, which makes an // asynchronous I/O request to the OS. if (acceptor.open (ACE_INET_Addr (this->port_), HTTP_Handler::MAX_REQUEST_SIZE + 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Acceptor::open"), -1); // Create the thread pool. // Register threads with the proactor and thread manager. Asynch_Thread_Pool_Task t (*ACE_Proactor::instance (), this->tm_); // The proactor threads are waiting on the I/O Completion Port. // Wait for the threads to finish. return this->tm_.wait (); #endif /* ACE_WIN32 */ return -1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; Sender sender; // Note: acceptor parameterized by the Receiver. ACE_Asynch_Acceptor<Receiver> acceptor; // If passive side if (host == 0) { if (acceptor.open (ACE_INET_Addr (port), initial_read_size, 1) == -1) return -1; } // If active side else if (sender.open (host, port) == -1) return -1; int success = 1; while (success > 0 && !done) // Dispatch events via Proactor singleton. success = ACE_Proactor::instance ()->handle_events (); return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_UNUSED_ARG (initial_read_size); if (parse_args (argc, argv) == -1) return -1; #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) ACE_WIN32_Proactor * pImpl = new ACE_WIN32_Proactor; #elif defined (ACE_HAS_AIO_CALLS) // ACE_POSIX_AIOCB_Proactor * pImpl = new ACE_POSIX_AIOCB_Proactor; ACE_POSIX_SIG_Proactor * pImpl = new ACE_POSIX_SIG_Proactor; #endif ACE_Proactor Proactor ( pImpl ,1 ); ACE_Proactor::instance( & Proactor ); MyTask Task1 ; if (Task1.activate (THR_NEW_LWP, nThreads ) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); } Sender sender; ACE_Asynch_Acceptor<Receiver> acceptor; int Rc = -1 ; if ( host == NULL ) // Acceptor { // Simplify , initial read with zero size Rc = acceptor.open (ACE_INET_Addr (port),0,1); } else { Rc = sender.open (host, port); } if ( Rc == 0 ) { char c ; cout << "Press any key to stop and exit=>\n" << flush ; cin.clear (); cin >> c ; }
int main (int argc, char *argv[]) { #if defined (sun) ACE_DEBUG ((LM_DEBUG, "\nSUN defined!\n")); #endif if (parse_args (argc, argv) == -1) return -1; disable_signal (ACE_SIGRTMIN, ACE_SIGRTMAX); MyTask task1; if (task1.activate (THR_NEW_LWP, threads) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); // wait for creation of Proactor task1.waitready (); Sender * send_list[MaxSenders]; ACE_Asynch_Acceptor<Receiver> acceptor; int rc = -1; int i; char c; if (host == 0) // Acceptor { // Simplify, initial read with zero size if (acceptor.open (ACE_INET_Addr (port),0,1) == 0) rc = 1; } else { for (i = 0; i < senders; ++i) send_list[i] = new Sender; for (i = 0; i < senders; ++i) if (send_list[i]->open (host, port) == 0) rc++; } if (rc > 0) { cout << "Press any key to stop=>" << flush; cin.clear (); cin >> c; }