Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / C++NPv1 / Thread_Per_Connection_Logging_Server.h
blob65f916146ae57a3b5d772ae1e2cfae9d605cbf67
1 /*
2 ** Copyright 2001 Addison Wesley. All Rights Reserved.
3 */
5 #ifndef _THREAD_PER_CONNECTION_LOGGING_SERVER_H
6 #define _THREAD_PER_CONNECTION_LOGGING_SERVER_H
8 #include "ace/SOCK_Stream.h"
9 #include "Logging_Server.h"
11 class Thread_Per_Connection_Logging_Server : public Logging_Server
13 private:
14 struct Thread_Args {
15 Thread_Args (Thread_Per_Connection_Logging_Server *lsp) : this_ (lsp) {}
17 Thread_Per_Connection_Logging_Server *this_;
18 ACE_SOCK_Stream logging_peer_;
21 // Passed as a parameter to <ACE_Thread_Manager::spawn>.
22 static ACE_THR_FUNC_RETURN run_svc (void *arg);
24 protected:
25 virtual int handle_connections ();
26 virtual int handle_data (ACE_SOCK_Stream * = 0);
28 public:
29 // Template Method that runs logging server's event loop. Need to
30 // reimplement this here because the threads spawned from handle_connections
31 // call handle_data; therefore, this method must not.
32 virtual int run (int argc, char *argv[]) {
33 if (open (argc > 1 ? atoi (argv[1]) : 0) == -1)
34 return -1;
36 for (;;) {
37 if (wait_for_multiple_events () == -1)
38 return -1;
39 if (handle_connections () == -1)
40 return -1;
43 ACE_NOTREACHED (return 0;)
47 #endif /* _THREAD_PER_CONNECTION_LOGGING_SERVER_H */