Doxygen changes
[ACE_TAO.git] / ACE / tests / Cached_Accept_Conn_Test.h
blob28f8d089211c2cab0e5edd4ab1fcfe87abe7774a
2 //=============================================================================
3 /**
4 * @file Cached_Accept_Conn_Test.h
6 * Define class needed for generating templates. IBM C++ requires this to
7 * be in its own file for auto template instantiation.
9 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
11 //=============================================================================
14 #ifndef ACE_TESTS_CACHED_ACCEPT_CONN_TEST_H
15 #define ACE_TESTS_CACHED_ACCEPT_CONN_TEST_H
17 #include "ace/SOCK_Connector.h"
18 #include "ace/SOCK_Acceptor.h"
19 #include "ace/SOCK_Stream.h"
20 #include "ace/INET_Addr.h"
21 #include "ace/Acceptor.h"
22 #include "ace/Connector.h"
23 #include "ace/Svc_Handler.h"
24 #include "ace/Caching_Utility_T.h"
25 #include "ace/Cached_Connect_Strategy_T.h"
26 #include "ace/Handle_Gobbler.h"
28 class Client_Svc_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
30 public:
32 Client_Svc_Handler (ACE_Thread_Manager *t = 0);
33 int open (void *v = 0);
34 int close (u_long flags = 0);
37 class Server_Svc_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
39 public:
41 Server_Svc_Handler (ACE_Thread_Manager *t = 0);
42 int open (void *v = 0);
45 typedef size_t ATTRIBUTES;
46 typedef std::pair<Client_Svc_Handler *, ATTRIBUTES>
47 CACHED_HANDLER;
48 typedef ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr>
49 ACE_ADDR;
50 typedef ACE_Hash<ACE_ADDR> H_KEY;
51 typedef ACE_Equal_To<ACE_ADDR> C_KEYS;
53 typedef ACE_Hash_Map_Manager_Ex<ACE_ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
54 HASH_MAP;
55 typedef ACE_Hash_Map_Iterator_Ex<ACE_ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
56 HASH_MAP_ITERATOR;
57 typedef ACE_Hash_Map_Reverse_Iterator_Ex<ACE_ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
58 HASH_MAP_REVERSE_ITERATOR;
60 typedef ACE_Recyclable_Handler_Cleanup_Strategy<ACE_ADDR, CACHED_HANDLER, HASH_MAP>
61 CLEANUP_STRATEGY;
62 typedef ACE_Recyclable_Handler_Caching_Utility<ACE_ADDR, CACHED_HANDLER, HASH_MAP, HASH_MAP_ITERATOR, ATTRIBUTES>
63 CACHING_UTILITY;
65 typedef ACE_LRU_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>
66 LRU_CACHING_STRATEGY;
68 typedef ACE_LFU_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>
69 LFU_CACHING_STRATEGY;
70 typedef ACE_FIFO_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>
71 FIFO_CACHING_STRATEGY;
72 typedef ACE_Null_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>
73 NULL_CACHING_STRATEGY;
74 typedef ACE_Caching_Strategy_Adapter<ATTRIBUTES, CACHING_UTILITY, LRU_CACHING_STRATEGY>
75 LRU_CACHING_STRATEGY_ADAPTER;
76 typedef ACE_Caching_Strategy_Adapter<ATTRIBUTES, CACHING_UTILITY, LFU_CACHING_STRATEGY>
77 LFU_CACHING_STRATEGY_ADAPTER;
78 typedef ACE_Caching_Strategy_Adapter<ATTRIBUTES, CACHING_UTILITY, FIFO_CACHING_STRATEGY>
79 FIFO_CACHING_STRATEGY_ADAPTER;
80 typedef ACE_Caching_Strategy_Adapter<ATTRIBUTES, CACHING_UTILITY, NULL_CACHING_STRATEGY>
81 NULL_CACHING_STRATEGY_ADAPTER;
82 typedef ACE_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>
83 CACHING_STRATEGY;
85 typedef ACE_Strategy_Acceptor<Server_Svc_Handler, ACE_SOCK_ACCEPTOR>
86 ACCEPTOR;
88 typedef ACE_Strategy_Connector<Client_Svc_Handler, ACE_SOCK_CONNECTOR>
89 STRATEGY_CONNECTOR;
91 typedef ACE_NOOP_Creation_Strategy<Client_Svc_Handler>
92 NULL_CREATION_STRATEGY;
94 typedef ACE_NOOP_Concurrency_Strategy<Client_Svc_Handler>
95 NULL_ACTIVATION_STRATEGY;
97 typedef ACE_Cached_Connect_Strategy_Ex<Client_Svc_Handler, ACE_SOCK_CONNECTOR, CACHING_STRATEGY, ATTRIBUTES, ACE_SYNCH_NULL_MUTEX>
98 CACHED_CONNECT_STRATEGY;
100 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
101 class Accept_Strategy : public ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>
103 public:
105 /// Constructor.
106 Accept_Strategy (CACHED_CONNECT_STRATEGY &caching_connect_strategy);
109 * Initialize the <peer_acceptor_> with <local_addr>. If the
110 * process runs out of descriptors, the unsed svc_handlers from the
111 * CONNECTION CACHE are removed.
113 int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
114 bool restart = false);
117 * The default behavior delegates to the <accept> method of the
118 * PEER_ACCEPTOR. A check is made here for the process running out
119 * of file descriptors. If so, the CONNECTION CACHE is purged of
120 * some idle svc_handlers.
122 int accept_svc_handler (SVC_HANDLER *svc_handler);
124 protected:
126 typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACCEPT_STRATEGY_BASE;
128 /// Handler for removing cached connections.
129 int out_of_sockets_handler (void);
131 CACHED_CONNECT_STRATEGY &caching_connect_strategy_;
134 #endif /* ACE_TESTS_CACHED_ACCEPT_CONN_TEST_H */