diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-08-31 20:45:46 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-08-31 20:45:46 +0000 |
commit | 331caf3d81d848c06e4a2a9f300a6ba7f46213ad (patch) | |
tree | dc8176cfb364ceea73cb2fa861a3e0c9dbe9eb3c /tests/Cached_Accept_Conn_Test.h | |
parent | e1dc8d11141481db8932adaba474b108f9b0a07c (diff) | |
download | ATCD-331caf3d81d848c06e4a2a9f300a6ba7f46213ad.tar.gz |
ChangeLogTag:Tue Aug 31 00:16:34 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
Diffstat (limited to 'tests/Cached_Accept_Conn_Test.h')
-rw-r--r-- | tests/Cached_Accept_Conn_Test.h | 128 |
1 files changed, 122 insertions, 6 deletions
diff --git a/tests/Cached_Accept_Conn_Test.h b/tests/Cached_Accept_Conn_Test.h index 377413621ce..d5ac4aad52d 100644 --- a/tests/Cached_Accept_Conn_Test.h +++ b/tests/Cached_Accept_Conn_Test.h @@ -1,14 +1,37 @@ // $Id$ + +// ============================================================================ +// +// = LIBRARY +// tests +// +// = FILENAME +// Cache_Accept_Conn_Test.h +// +// = DESCRIPTION +// Define class needed for generating templates. IBM C++ requires this to +// be in its own file for auto template instantiation. // -// Contains classes for Cached_Accept_Conn_Test which are used in automatic -// template instantiation - IBM C++ requires these to be in their own header. +// = AUTHOR +// Kirthika Parameswaran <kirthika@cs.wustl.edu> +// +// ============================================================================ -#ifndef __CACHED_ACCEPT_CONN_TEST_H -#define __CACHED_ACCEPT_CONN_TEST_H +#ifndef ACE_TESTS_CACHED_ACCEPT_CONN_TEST_H +#define ACE_TESTS_CACHED_ACCEPT_CONN_TEST_H +#include "ace/Strategies.h" +#include "ace/SOCK_Connector.h" +#include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Stream.h" +#include "ace/INET_Addr.h" +#include "ace/Acceptor.h" +#include "ace/Connector.h" #include "ace/Svc_Handler.h" #include "ace/Synch.h" +#include "ace/Caching_Utility_T.h" +#include "ace/Cached_Connect_Strategy_T.h" +#include "ace/Handle_Gobbler.h" class Client_Svc_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> { @@ -19,7 +42,6 @@ public: int close (u_long flags = 0); }; - class Server_Svc_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> { public: @@ -28,4 +50,98 @@ public: int open (void *v = 0); }; -#endif /* __CACHED_ACCEPT_CONN_TEST_H */ +typedef size_t ATTRIBUTES; +typedef ACE_Pair<Client_Svc_Handler *, ATTRIBUTES> + CACHED_HANDLER; +typedef ACE_Refcounted_Hash_Recyclable<ACE_INET_Addr> + ACE_ADDR; +typedef ACE_Hash<ACE_ADDR> H_KEY; +typedef ACE_Equal_To<ACE_ADDR> C_KEYS; + +typedef ACE_Hash_Map_Manager_Ex<ACE_ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex> + HASH_MAP; +typedef ACE_Hash_Map_Iterator_Ex<ACE_ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex> + HASH_MAP_ITERATOR; +typedef ACE_Hash_Map_Reverse_Iterator_Ex<ACE_ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex> + HASH_MAP_REVERSE_ITERATOR; + +typedef ACE_Recyclable_Handler_Cleanup_Strategy<ACE_ADDR, CACHED_HANDLER, HASH_MAP> + CLEANUP_STRATEGY; +typedef ACE_Recyclable_Handler_Caching_Utility<ACE_ADDR, CACHED_HANDLER, HASH_MAP, HASH_MAP_ITERATOR, ATTRIBUTES> + CACHING_UTILITY; + +typedef ACE_LRU_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY> + LRU_CACHING_STRATEGY; + +#if defined (ACE_HAS_BROKEN_EXTENDED_TEMPLATES) + +typedef LRU_CACHING_STRATEGY + CACHING_STRATEGY; + +#else + +typedef ACE_LFU_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY> + LFU_CACHING_STRATEGY; +typedef ACE_FIFO_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY> + FIFO_CACHING_STRATEGY; +typedef ACE_Null_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY> + NULL_CACHING_STRATEGY; +typedef ACE_Caching_Strategy_Adapter<ATTRIBUTES, CACHING_UTILITY, LRU_CACHING_STRATEGY> + LRU_CACHING_STRATEGY_ADAPTER; +typedef ACE_Caching_Strategy_Adapter<ATTRIBUTES, CACHING_UTILITY, LFU_CACHING_STRATEGY> + LFU_CACHING_STRATEGY_ADAPTER; +typedef ACE_Caching_Strategy_Adapter<ATTRIBUTES, CACHING_UTILITY, FIFO_CACHING_STRATEGY> + FIFO_CACHING_STRATEGY_ADAPTER; +typedef ACE_Caching_Strategy_Adapter<ATTRIBUTES, CACHING_UTILITY, NULL_CACHING_STRATEGY> + NULL_CACHING_STRATEGY_ADAPTER; +typedef ACE_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY> + CACHING_STRATEGY; + +#endif /* ACE_HAS_BROKEN_EXTENDED_TEMPLATES */ + +typedef ACE_Strategy_Acceptor<Server_Svc_Handler, ACE_SOCK_ACCEPTOR> + ACCEPTOR; + +typedef ACE_Strategy_Connector<Client_Svc_Handler, ACE_SOCK_CONNECTOR> + STRATEGY_CONNECTOR; + +typedef ACE_NOOP_Creation_Strategy<Client_Svc_Handler> + NULL_CREATION_STRATEGY; + +typedef ACE_NOOP_Concurrency_Strategy<Client_Svc_Handler> + NULL_ACTIVATION_STRATEGY; + +typedef ACE_Cached_Connect_Strategy_Ex<Client_Svc_Handler, ACE_SOCK_CONNECTOR, CACHING_STRATEGY, ATTRIBUTES, ACE_SYNCH_NULL_MUTEX> + CACHED_CONNECT_STRATEGY; + +template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> +class Accept_Strategy : public ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> +{ +public: + + Accept_Strategy (CACHED_CONNECT_STRATEGY &caching_connect_strategy); + // Constructor. + + int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + int restart = 0); + // Initialize the <peer_acceptor_> with <local_addr>. If the + // process runs out of descriptors, the unsed svc_handlers from the + // CONNECTION CACHE are removed. + + int accept_svc_handler (SVC_HANDLER *svc_handler); + // The default behavior delegates to the <accept> method of the + // PEER_ACCEPTOR. A check is made here for the process running out + // of file descriptors. If so, the CONNECTION CACHE is purged of + // some idle svc_handlers. + +protected: + + typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACCEPT_STRATEGY_BASE; + + int out_of_sockets_handler (void); + // Handler for removing cached connections. + + CACHED_CONNECT_STRATEGY &caching_connect_strategy_; +}; + +#endif /* ACE_TESTS_CACHED_ACCEPT_CONN_TEST_H */ |