summaryrefslogtreecommitdiff
path: root/examples/Web_Crawler
diff options
context:
space:
mode:
authorkirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-03 21:58:27 +0000
committerkirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-03 21:58:27 +0000
commitf623106a8c35b5ff73b57f3e22c6be03324e9e3e (patch)
tree32474aac278b2396d1c98e9a133282da0fa0dcea /examples/Web_Crawler
parentb314a8957a564518f3f5dc684f3d5d09f7eea33d (diff)
downloadATCD-f623106a8c35b5ff73b57f3e22c6be03324e9e3e.tar.gz
removed since added to ace lib itself.
Diffstat (limited to 'examples/Web_Crawler')
-rw-r--r--examples/Web_Crawler/Cached_Connect_Strategy_T.cpp643
-rw-r--r--examples/Web_Crawler/Cached_Connect_Strategy_T.h249
2 files changed, 0 insertions, 892 deletions
diff --git a/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp b/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp
deleted file mode 100644
index bdb7047736e..00000000000
--- a/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp
+++ /dev/null
@@ -1,643 +0,0 @@
-//$Id:
-
-#ifndef CACHED_CONNECT_STRATEGY_T_C
-#define CACHED_CONNECT_STRATEGY_T_C
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-#define ACE_LACKS_PRAGMA_ONCE
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/ACE.h"
-#include "Cached_Connect_Strategy_T.h"
-#include "ace/Service_Repository.h"
-#include "ace/Synch.h"
-#include "ace/Service_Types.h"
-#include "ace/Thread_Manager.h"
-#include "ace/WFMO_Reactor.h"
-#include "ace/Pair_T.h"
-#include "Options.h"
-
-#if defined (ACE_LACKS_INLINE_FUNCTIONS)
-#include "Cached_Connect_Strategy_T.i"
-#endif /* ACE_LACKS_INLINE_FUNCTIONS */
-
-ACE_RCSID(Web_Crawler, Cached_Connect_Strategy_T, "$Id$")
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX>
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::ACE_Cached_Connect_Strategy_Ex
- (ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
- ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
- ACE_Recycling_Strategy<SVC_HANDLER> *rec_s)
- : creation_strategy_ (0),
- delete_creation_strategy_ (0),
- concurrency_strategy_ (0),
- delete_concurrency_strategy_ (0),
- recycling_strategy_ (0),
- delete_recycling_strategy_ (0)
-{
-
- ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::ACE_Cached_Connect_Strategy_Ex\n"));
-
- if (this->open (cre_s, con_s, rec_s) == -1)
- ACE_ERROR ((LM_ERROR,
- ASYS_TEXT ("%p\n"),
- ASYS_TEXT ("ACE_Cached_Connect_Strategy_Ex::ACE_Cached_Connect_Strategy_Ex")));
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX>
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::~ACE_Cached_Connect_Strategy_Ex (void)
-{
- ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::~ACE_Cached_Connect_Strategy_Ex\n"));
- if (this->delete_creation_strategy_)
- delete this->creation_strategy_;
- this->delete_creation_strategy_ = 0;
- this->creation_strategy_ = 0;
-
- if (this->delete_concurrency_strategy_)
- delete this->concurrency_strategy_;
- this->delete_concurrency_strategy_ = 0;
- this->concurrency_strategy_ = 0;
-
- if (this->delete_recycling_strategy_)
- delete this->recycling_strategy_;
- this->delete_recycling_strategy_ = 0;
- this->recycling_strategy_ = 0;
-
- // Close down all cached service handlers.
- for (CONNECTION_CACHE_ITERATOR iter = this->connection_cache_.begin ();
- iter != this->connection_cache_.end ();
- ++iter)
- {
- if ((*iter).second () != 0)
- {
- (*iter).second ()->recycler (0, 0);
- (*iter).second ()->close ();
- }
- }
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::open
- (ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
- ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
- ACE_Recycling_Strategy<SVC_HANDLER> *rec_s)
-{
- // Initialize the creation strategy.
- // First we decide if we need to clean up.
- if (this->creation_strategy_ != 0 &&
- this->delete_creation_strategy_ != 0 &&
- cre_s != 0)
- {
- delete this->creation_strategy_;
- this->creation_strategy_ = 0;
- this->delete_creation_strategy_ = 0;
- }
-
- if (cre_s != 0)
- this->creation_strategy_ = cre_s;
- else if (this->creation_strategy_ == 0)
- {
- ACE_NEW_RETURN (this->creation_strategy_,
- CREATION_STRATEGY, -1);
- this->delete_creation_strategy_ = 1;
- }
-
- // Initialize the concurrency strategy.
-
- if (this->concurrency_strategy_ != 0 &&
- this->delete_concurrency_strategy_ != 0 &&
- con_s != 0)
- {
- delete this->concurrency_strategy_;
- this->concurrency_strategy_ = 0;
- this->delete_concurrency_strategy_ = 0;
- }
-
- if (con_s != 0)
- this->concurrency_strategy_ = con_s;
- else if (this->concurrency_strategy_ == 0)
- {
- ACE_NEW_RETURN (this->concurrency_strategy_,
- CONCURRENCY_STRATEGY, -1);
- this->delete_concurrency_strategy_ = 1;
- }
-
- // Initialize the recycling strategy.
-
- if (this->recycling_strategy_ != 0 &&
- this->delete_recycling_strategy_ != 0 &&
- rec_s != 0)
- {
- delete this->recycling_strategy_;
- this->recycling_strategy_ = 0;
- this->delete_recycling_strategy_ = 0;
- }
-
- if (rec_s != 0)
- this->recycling_strategy_ = rec_s;
- else if (this->recycling_strategy_ == 0)
- {
- ACE_NEW_RETURN (this->recycling_strategy_,
- RECYCLING_STRATEGY, -1);
- this->delete_recycling_strategy_ = 1;
- }
-
- return 0;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::check_hint_i
- (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry,
- int &found)
-{
- ACE_UNUSED_ARG (remote_addr);
- ACE_UNUSED_ARG (timeout);
- ACE_UNUSED_ARG (local_addr);
- ACE_UNUSED_ARG (reuse_addr);
- ACE_UNUSED_ARG (flags);
- ACE_UNUSED_ARG (perms);
-
- found = 0;
-
- // Get the recycling act for the svc_handler
- CONNECTION_CACHE_ENTRY *possible_entry = (CONNECTION_CACHE_ENTRY *) sh->recycling_act ();
-
- // Check to see if the hint svc_handler has been closed down
- if (possible_entry->ext_id_.state () == ACE_Recyclable::CLOSED)
- {
- // If close, decrement refcount
- if (possible_entry->ext_id_.decrement () == 0)
- {
- // If refcount goes to zero, close down the svc_handler
- possible_entry->int_id_.first ()->recycler (0, 0);
- possible_entry->int_id_.first ()->close ();
- this->purge_i (possible_entry);
- }
-
- // Hint not successful
- found = 0;
-
- // Reset hint
- sh = 0;
- }
-
- // If hint is not closed, see if it is connected to the correct
- // address and is recyclable
- else if (possible_entry->ext_id_ == remote_addr)
- {
- // Hint successful
- found = 1;
-
- // Tell the <svc_handler> that it should prepare itself for
- // being recycled.
- this->prepare_for_recycling (sh);
- }
- else
- {
- // This hint will not be used.
- possible_entry->ext_id_.decrement ();
-
- // Hint not successful
- found = 0;
-
- // If <sh> is not connected to the correct address or is busy,
- // we will not use it.
- sh = 0;
- }
-
- if (found)
- entry = possible_entry;
-
- return 0;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::find_or_create_svc_handler_i
- (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry,
- int &found)
-{
-
- ACE::set_handle_limit (OPTIONS::instance ()->handle_limit ());
- //ACE_DEBUG ((LM_DEBUG, "MAX handles %d \n", ACE::max_handles ()));
- // Explicit type conversion
- REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr);
-
- // Try to find the address in the cache. Only if we don't find it
- // do we create a new <SVC_HANDLER> and connect it with the server.
- if (this->connection_cache_.find (search_addr, entry) == -1)
- {
- // Set the flag
- found = 0;
-
- // Create a new svc_handler
- if (this->make_svc_handler (sh) == -1)
- return -1;
-
- if (this->connect (...) == -1)
- {
- return -1;
- }
- else
- {
- // Insert the new SVC_HANDLER instance into the cache.
- if (this->connection_cache_.bind (search_addr,
- sh,
- entry) == -1)
- return -1;
-
- // Set the recycler and the recycling act
- this->assign_recycler (sh, this, entry);
- }
- }
- else // We found a cached svc_handler.
- {
- // Set the flag
- found = 1;
-
- // Get the cached <svc_handler>
- sh = entry->int_id_.first ();
-
- // Tell the <svc_handler> that it should prepare itself for
- // being recycled.
- this->prepare_for_recycling (sh);
- }
-
- return 0;
-
-}
-
-connect ()
-{
- // Actively establish the connection. This is a timed blocking
- // connect.
- if (this->CONNECT_STRATEGY::connect_svc_handler (sh,
- remote_addr,
- timeout,
- local_addr,
- reuse_addr,
- flags,
- perms) == -1)
- {
- // If connect() failed because of timeouts, we have to reject
- // the connection entirely. This is necessary since currently
- // there is no way for the non-blocking connects to complete and
- // for the <Connector> to notify the cache of the completion of
- // connect().
- if (errno == EWOULDBLOCK)
- errno = ENOTSUP;
- else if (errno == EMFILE)
- {
- // @@purge here...
-
- // Try connecting again.
- if (this->CONNECT_STRATEGY::connect_svc_handler (sh,
- remote_addr,
- timeout,
- local_addr,
- reuse_addr,
- flags,
- perms) == -1)
- {
- if (errno == EWOULDBLOCK)
- errno = ENOTSUP;
- return -1;
- }
- }
- else
- {
- return -1;
- }
- }
- else
- {
- return 0;
- }
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::connect_svc_handler
- (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms)
-{
-
- ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::connect_svc_handler\n"));
- int found = 0;
-
- // This artificial scope is required since we need to let go of the
- // lock *before* registering the newly created handler with the
- // Reactor.
- {
- // Synchronization is required here as the setting of the
- // recyclable state must be done atomically with the finding and
- // binding of the service handler in the cache.
- ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1);
-
- int result = this->connect_svc_handler_i (sh,
- remote_addr,
- timeout,
- local_addr,
- reuse_addr,
- flags,
- perms,
- found);
- if (result != 0)
- return result;
-
- }
-
- // If it is a new connection, activate it.
- //
- // Note: This activation is outside the scope of the lock of the
- // cached connector. This is necessary to avoid subtle deadlock
- // conditions with this lock and the Reactor lock.
- //
- // @@ If an error occurs on activation, we should try to remove this
- // entry from the internal table.
-
- if (!found)
- if (this->activate_svc_handler (sh))
- return -1;
-
- return 0;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::connect_svc_handler
- (SVC_HANDLER *&sh,
- SVC_HANDLER *&sh_copy,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms)
-{
- int found = 0;
-
- // This artificial scope is required since we need to let go of the
- // lock *before* registering the newly created handler with the
- // Reactor.
- {
- // Synchronization is required here as the setting of the
- // recyclable state must be done atomically with the finding and
- // binding of the service handler in the cache.
- ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1);
-
- int result = this->connect_svc_handler_i (sh,
- remote_addr,
- timeout,
- local_addr,
- reuse_addr,
- flags,
- perms,
- found);
- sh_copy = sh;
-
- ACE_DEBUG ((LM_DEBUG,"after connect_svc_handler_i ACE_Cached_Connect_Strategy_Ex::connect_svc_handler sh_Copy result =%d\n", result));
- if (result != 0)
- return result;
-
- }
-
- // If it is a new connection, activate it.
- //
- // Note: This activation is outside the scope of the lock of the
- // cached connector. This is necessary to avoid subtle deadlock
- // conditions with this lock and the Reactor lock.
- //
- // @@ If an error occurs on activation, we should try to remove this
- // entry from the internal table.
-
- if (!found)
- if (this->activate_svc_handler (sh))
- return -1;
-
- return 0;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::connect_svc_handler_i
- (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- int& found)
-{
- CONNECTION_CACHE_ENTRY *entry = 0;
-
- // Check if the user passed a hint svc_handler
- if (sh != 0)
- {
-
- int result = this->check_hint_i (sh,
- remote_addr,
- timeout,
- local_addr,
- reuse_addr,
- flags,
- perms,
- entry,
- found);
- // @@ Remove debugging
- ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::connect_svc_handler_i CHECK_HINT_I result = %d\n", result));
-
- if (result != 0)
- return result;
- }
-
- // If not found
- if (!found)
- {
- int result = this->find_or_create_svc_handler_i (sh,
- remote_addr,
- timeout,
- local_addr,
- reuse_addr,
- flags,
- perms,
- entry,
- found);
-
- // @@ Purging here is not correct...
-
- if (result != 0)
- {
- // If the connect failed due to the process running out of
- // file descriptors then, auto_purging of some connections
- // are done from the CONNECTION_CACHE. This frees the
- // descriptors which get used in the connect process and
- // hence the same method is called again!
- if (errno == EMFILE)
- {
- int result = this->connection_cache_.purge ();
- if (result == -1)
- return result;
-
- if (this->find_or_create_svc_handler_i (sh,
- remote_addr,
- timeout,
- local_addr,
- reuse_addr,
- flags,
- perms,
- entry,
- found) == -1)
- return -1;
- }
- else
- return result;
- }
- }
-
- // For all successful cases: mark the <svc_handler> in the cache
- // as being <in_use>. Therefore recyclable is BUSY.
- entry->ext_id_.state (ACE_Recyclable::BUSY);
-
- // And increment the refcount
- entry->ext_id_.increment ();
-
- return 0;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::cache (const void *recycling_act)
-{
- // Synchronization is required here as the setting of the recyclable
- // state must be done atomically with respect to other threads that
- // are querying the cache.
- ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1);
-
- ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::cache\n"));
- return this->cache_i (recycling_act);
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::cache_i (const void *recycling_act)
-{
- // The wonders and perils of ACT
- CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
-
- // Mark the <svc_handler> in the cache as not being <in_use>.
- // Therefore recyclable is IDLE.
-
- entry->ext_id_.state (ACE_Recyclable::IDLE);
-
- return 0;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::purge (const void *recycling_act)
-{
- // Excluded other threads from changing cache while we take this
- // entry out.
- ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1);
-
- return this->purge_i (recycling_act);
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::purge_i (const void *recycling_act)
-{
- // The wonders and perils of ACT
- CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
-
- return this->connection_cache_.unbind (entry);
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::mark_as_closed (const void *recycling_act)
-{
- // Excluded other threads from changing cache while we take this
- // entry out.
- ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1);
-
- return this->mark_as_closed_i (recycling_act);
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::mark_as_closed_i (const void *recycling_act)
-{
- // The wonders and perils of ACT
- CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
-
- // Mark the <svc_handler> in the cache as CLOSED.
- entry->ext_id_.state (ACE_Recyclable::CLOSED);
-
- return 0;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::cleanup_hint (const void *recycling_act)
-{
- // Excluded other threads from changing cache while we take this
- // entry out.
- ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1);
-
- return this->cleanup_hint_i (recycling_act);
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::cleanup_hint_i (const void *recycling_act)
-{
- // The wonders and perils of ACT
- CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
-
- // Decrement the refcount on the <svc_handler>.
- int refcount = entry->ext_id_.decrement ();
-
- // If the svc_handler state is closed and the refcount == 0, call
- // close() on svc_handler.
- if (entry->ext_id_.state () == ACE_Recyclable::CLOSED &&
- refcount == 0)
- {
- entry->int_id_.first ()->recycler (0, 0);
- entry->int_id_.first ()->close ();
- this->purge_i (entry);
- }
-
- return 0;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_Creation_Strategy<SVC_HANDLER> *
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::creation_strategy (void) const
-{
- return this->creation_strategy_;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_Recycling_Strategy<SVC_HANDLER> *
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::recycling_strategy (void) const
-{
- return this->recycling_strategy_;
-}
-
-template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> ACE_Concurrency_Strategy<SVC_HANDLER> *
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::concurrency_strategy (void) const
-{
- return this->concurrency_strategy_;
-}
-
-ACE_ALLOC_HOOK_DEFINE(ACE_Cached_Connect_Strategy_Ex)
-
-#endif /* CACHED_CONNECT_STRATEGY_T_C */
diff --git a/examples/Web_Crawler/Cached_Connect_Strategy_T.h b/examples/Web_Crawler/Cached_Connect_Strategy_T.h
deleted file mode 100644
index 2f81d41a33b..00000000000
--- a/examples/Web_Crawler/Cached_Connect_Strategy_T.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/* -*- C++ -*- */
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// ace
-//
-// = FILENAME
-// Cached_Connect_Strategy_T.h
-//
-// = AUTHOR
-// Kirthika Parameswaran
-//
-// ============================================================================
-
-#ifndef CACHED_CONNECT_STRATEGY_T_H
-#define CACHED_CONNECT_STRATEGY_T_H
-
-#include "ace/Strategies_T.h"
-#include "ace/Hash_Map_Manager_T.h"
-#include "Optimal_Cache_Map_Manager_T.h"
-#include "Caching_Strategies_T.h"
-#include "ace/Functor_T.h"
-#include "ace/Pair_T.h"
-#include "ace/Synch.h"
-
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX>
-class ACE_Cached_Connect_Strategy_Ex : public ACE_Connection_Recycling_Strategy, public ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>
-{
- // = TITLE
- // A connection strategy which caches connections to peers
- // (represented by <SVC_HANDLER> instances), thereby allowing
- // subsequent re-use of unused, but available, connections.
- //
- // = DESCRIPTION
- // <Mem_Cached_Connect_Strategy> is intended to be used as a
- // plug-in connection strategy for <ACE_Strategy_Connector>.
- // It's added value is re-use of established connections.
- //
- // = USAGE
- // In order to use this appropriately, the user must provide
- // a template specialization for <ACE_Hash_Addr::compare_i()> and
- // <ACE_Hash_Addr::hash_i()> based on the address type and the
- // service handler type. For example, a specialization using
- // <ACE_INET_Addr> and <My_Service_Handler> might be:
- // = BEGIN<NOFILL>
- // = BEGIN<CODE>
- // size_t
- // ACE_Hash_Addr<ACE_INET_Addr, My_Service_Handler>::hash_i(const ACE_INET_Addr &a)
- // {
- // return ...;
- // }
- // = END<CODE>
- // = END<NOFILL>
- //
- // = SEE ALSO
- // <ACE_Hash_Addr>.
-public:
-
- ACE_Cached_Connect_Strategy_Ex (ACE_Creation_Strategy<SVC_HANDLER> *cre_s = 0,
- ACE_Concurrency_Strategy<SVC_HANDLER> *con_s = 0,
- ACE_Recycling_Strategy<SVC_HANDLER> *rec_s = 0);
- // Constructor
-
- virtual ~ACE_Cached_Connect_Strategy_Ex (void);
- // Destructor
-
- virtual int open (ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
- ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
- ACE_Recycling_Strategy<SVC_HANDLER> *rec_s);
- // This methods allow you to change the strategies used by the
- // cached connector.
-
- virtual int make_svc_handler (SVC_HANDLER *&sh);
- // Template method for making a new <svc_handler>
-
- virtual int activate_svc_handler (SVC_HANDLER *svc_handler);
- // Template method for activating a new <svc_handler>
-
- virtual int assign_recycler (SVC_HANDLER *svc_handler,
- ACE_Connection_Recycling_Strategy *recycler,
- const void *recycling_act);
- // Template method for setting the recycler information of the
- // svc_handler.
-
- virtual int prepare_for_recycling (SVC_HANDLER *svc_handler);
- // Template method for preparing the svc_handler for recycling.
-
- virtual int connect_svc_handler (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms);
-
- virtual int connect_svc_handler (SVC_HANDLER *&sh,
- SVC_HANDLER *&sh_copy,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms);
- // Checks to see if there is already a <SVC_HANDLER> in the cache
- // connected to the <remote_addr>. If so, we return this pointer.
- // Otherwise we establish the connection, put it into the cache, and
- // return the <SVC_HANDLER> pointer. <[NOTE]>: the <{reuse_addr}>
- // argument does NOT control re-use of addresses in the cache.
- // Rather, if the underlying protocol requires a "dead time" prior
- // to re-use of its addresses (TCP is a classic example of this),
- // <{and}> the protocol provides a means by which to defeat the dead
- // time, setting this argument to non-zero will defeat the dead-time
- // requirement. <{Dev. Note: We might want to consider enhancing
- // the interface at some point so that this also controls re-use of
- // the cache.}>
-
- virtual int purge (const void *recycling_act);
- // Remove from cache.
-
- virtual int cache (const void *recycling_act);
- // Add to cache.
-
- virtual int mark_as_closed (const void *recycling_act);
- // Mark as closed.
-
- virtual int cleanup_hint (const void *recycling_act);
- // Cleanup hint.
-
- // = Define some useful typedefs.
- typedef ACE_Creation_Strategy<SVC_HANDLER>
- CREATION_STRATEGY;
- typedef ACE_Concurrency_Strategy<SVC_HANDLER>
- CONCURRENCY_STRATEGY;
- typedef ACE_Recycling_Strategy<SVC_HANDLER>
- RECYCLING_STRATEGY;
-
- // = Super class
- typedef ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>
- CONNECT_STRATEGY;
-
- // = Typedefs for managing the map
- typedef ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>
- REFCOUNTED_HASH_RECYCLABLE_ADDRESS;
-
- typedef ACE_Optimal_Cache_Map_Manager<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, CACHING_STRATEGY>
- CONNECTION_CACHE;
- typedef ACE_Optimal_Cache_Map_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, CACHING_STRATEGY>
- CONNECTION_CACHE_ITERATOR;
- typedef ACE_Optimal_Cache_Map_Reverse_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, CACHING_STRATEGY>
- CONNECTION_CACHE_REVERSE_ITERATOR;
-
- typedef ACE_TYPENAME CONNECTION_CACHE::CACHE_ENTRY
- CONNECTION_CACHE_ENTRY;
- // = Strategy accessors
- virtual ACE_Creation_Strategy<SVC_HANDLER> *creation_strategy (void) const;
- virtual ACE_Recycling_Strategy<SVC_HANDLER> *recycling_strategy (void) const;
- virtual ACE_Concurrency_Strategy<SVC_HANDLER> *concurrency_strategy (void) const;
-
-protected:
-
- virtual int purge_i (const void *recycling_act);
- // Remove from cache (non-locking version).
-
- virtual int cache_i (const void *recycling_act);
- // Add to cache (non-locking version).
-
- virtual int mark_as_closed_i (const void *recycling_act);
- // Mark as closed (non-locking version).
-
- virtual int cleanup_hint_i (const void *recycling_act);
- // Cleanup hint.
-
- // = Helpers
- int check_hint_i (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry,
- int &found);
-
- int connect_svc_handler_i (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- int &found);
-
- int find_or_create_svc_handler_i (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry,
- int &found);
-
- CONNECTION_CACHE connection_cache_;
- // Table that maintains the cache of connected <SVC_HANDLER>s.
-
- MUTEX lock_;
- // Mutual exclusion for this object.
-
- // = Strategy objects.
-
- CREATION_STRATEGY *creation_strategy_;
- // Creation strategy for an <Connector>.
-
- int delete_creation_strategy_;
- // 1 if <Connector> created the creation strategy and thus should
- // delete it, else 0.
-
- CONCURRENCY_STRATEGY *concurrency_strategy_;
- // Concurrency strategy for an <Connector>.
-
- int delete_concurrency_strategy_;
- // 1 if <Connector> created the concurrency strategy and thus should
- // delete it, else 0.
-
- RECYCLING_STRATEGY *recycling_strategy_;
- // Recycling strategy for an <Connector>.
-
- int delete_recycling_strategy_;
- // 1 if <Connector> created the recycling strategy and thus should
- // delete it, else 0.
-};
-
-
-
-#if !defined (ACE_LACKS_INLINE_FUNCTIONS)
-#include "Cached_Connect_Strategy_T.i"
-#endif /* ACE_LACKS_INLINE_FUNCTIONS */
-
-#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
-#include "Cached_Connect_Strategy_T.cpp"
-#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
-
-#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
-#pragma implementation ("Cached_Connect_Strategy_T.cpp")
-#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
-
-#endif /* CACHED_CONNECT_STRATEGY_T_H */