summaryrefslogtreecommitdiff
path: root/docs/tutorials/007/client_acceptor.h
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/007/client_acceptor.h')
-rw-r--r--docs/tutorials/007/client_acceptor.h156
1 files changed, 80 insertions, 76 deletions
diff --git a/docs/tutorials/007/client_acceptor.h b/docs/tutorials/007/client_acceptor.h
index e1c0eded6fd..82c761879ea 100644
--- a/docs/tutorials/007/client_acceptor.h
+++ b/docs/tutorials/007/client_acceptor.h
@@ -7,15 +7,19 @@
/*
The ACE_Acceptor<> template lives in the ace/Acceptor.h header file. You'll
find a very consitent naming convention between the ACE objects and the
- headers where they can be found. In general, the ACE object ACE_Foobar will
- be found in ace/Foobar.h.
+ headers where they can be found. In general, the ACE object ACE_Foobar will
+ be found in ace/Foobar.h.
*/
#include "ace/Acceptor.h"
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
/*
Since we want to work with sockets, we'll need a SOCK_Acceptor to allow the
- clients to connect to us.
+ clients to connect to us.
*/
#include "ace/SOCK_Acceptor.h"
@@ -23,7 +27,7 @@
The Client_Handler object we develop will be used to handle clients once
they're connected. The ACE_Acceptor<> template's first parameter requires
such an object. In some cases, you can get by with just a forward
- declaration on the class, in others you have to have the whole thing.
+ declaration on the class, in others you have to have the whole thing.
*/
#include "client_handler.h"
@@ -32,7 +36,7 @@
connection attempts and create Client_Handler objects when they happen. In
Tutorial 001, we wrote the basic acceptor logic on our own before we
realized that ACE_Acceptor<> was available. You'll get spoiled using the
- ACE templates because they take away a lot of the tedious details!
+ ACE templates because they take away a lot of the tedious details!
*/
typedef ACE_Acceptor < Client_Handler, ACE_SOCK_ACCEPTOR > Client_Acceptor_Base;
@@ -57,81 +61,81 @@ typedef ACE_Acceptor < Client_Handler, ACE_SOCK_ACCEPTOR > Client_Acceptor_Base;
class Client_Acceptor : public Client_Acceptor_Base
{
public:
- typedef Client_Acceptor_Base inherited;
-
- /*
- Now that we have more than two strategies, we need more than a boolean
- to tell us what we're using. A set of enums is a good choice because
- it allows us to use named values. Another option would be a set of
- static const integers.
- */
- enum concurrency_t
- {
- single_threaded_,
- thread_per_connection_,
- thread_pool_
- };
-
- /*
- The default constructor allows the programmer to choose the concurrency
- strategy. Since we want to focus on thread-pool, that's what we'll use
- if nothing is specified.
- */
- Client_Acceptor( int _concurrency = thread_pool_ );
-
- /*
- Another option is to construct the object with an existing thread pool.
- The concurrency strategy is pretty obvious at that point.
- */
- Client_Acceptor( Thread_Pool & _thread_pool );
-
- /*
- Our destructor will take care of shutting down the thread-pool
- if applicable.
- */
- ~Client_Acceptor( void );
-
- /*
- Open ourselves and register with the given reactor. The thread pool size
- can be specified here if you want to use that concurrency strategy.
- */
- int open( const ACE_INET_Addr & _addr, ACE_Reactor * _reactor,
- int _pool_size = Thread_Pool::default_pool_size_ );
-
- /*
- Close ourselves and our thread pool if applicable
- */
- int close(void);
-
- /*
- What is our concurrency strategy?
- */
- int concurrency(void)
- { return this->concurrency_; }
-
- /*
- Give back a pointer to our thread pool. Our Client_Handler objects
- will need this so that their handle_input() methods can put themselves
- into the pool. Another alternative would be a globally accessible
- thread pool. ACE_Singleton<> is a way to achieve that.
- */
- Thread_Pool * thread_pool(void)
- { return & this->the_thread_pool_; }
-
- /*
- Since we can be constructed with a Thread_Pool reference, there are times
- when we need to know if the thread pool we're using is ours or if we're
- just borrowing it from somebody else.
- */
- int thread_pool_is_private(void)
- { return &the_thread_pool_ == &private_thread_pool_; }
+ typedef Client_Acceptor_Base inherited;
+
+ /*
+ Now that we have more than two strategies, we need more than a boolean
+ to tell us what we're using. A set of enums is a good choice because
+ it allows us to use named values. Another option would be a set of
+ static const integers.
+ */
+ enum concurrency_t
+ {
+ single_threaded_,
+ thread_per_connection_,
+ thread_pool_
+ };
+
+ /*
+ The default constructor allows the programmer to choose the concurrency
+ strategy. Since we want to focus on thread-pool, that's what we'll use
+ if nothing is specified.
+ */
+ Client_Acceptor( int _concurrency = thread_pool_ );
+
+ /*
+ Another option is to construct the object with an existing thread pool.
+ The concurrency strategy is pretty obvious at that point.
+ */
+ Client_Acceptor( Thread_Pool & _thread_pool );
+
+ /*
+ Our destructor will take care of shutting down the thread-pool
+ if applicable.
+ */
+ ~Client_Acceptor( void );
+
+ /*
+ Open ourselves and register with the given reactor. The thread pool size
+ can be specified here if you want to use that concurrency strategy.
+ */
+ int open( const ACE_INET_Addr & _addr, ACE_Reactor * _reactor,
+ int _pool_size = Thread_Pool::default_pool_size_ );
+
+ /*
+ Close ourselves and our thread pool if applicable
+ */
+ int close(void);
+
+ /*
+ What is our concurrency strategy?
+ */
+ int concurrency(void)
+ { return this->concurrency_; }
+
+ /*
+ Give back a pointer to our thread pool. Our Client_Handler objects
+ will need this so that their handle_input() methods can put themselves
+ into the pool. Another alternative would be a globally accessible
+ thread pool. ACE_Singleton<> is a way to achieve that.
+ */
+ Thread_Pool * thread_pool(void)
+ { return & this->the_thread_pool_; }
+
+ /*
+ Since we can be constructed with a Thread_Pool reference, there are times
+ when we need to know if the thread pool we're using is ours or if we're
+ just borrowing it from somebody else.
+ */
+ int thread_pool_is_private(void)
+ { return &the_thread_pool_ == &private_thread_pool_; }
protected:
- int concurrency_;
+ int concurrency_;
- Thread_Pool private_thread_pool_;
+ Thread_Pool private_thread_pool_;
- Thread_Pool & the_thread_pool_;
+ Thread_Pool & the_thread_pool_;
};
#endif // CLIENT_ACCEPTOR_H