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