Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / Strategies_T.cpp
blobcd2935aadf3c620a68b4bc5d04dde96beb5e5e65
1 // $Id: Strategies_T.cpp 82294 2008-07-12 13:03:37Z johnnyw $
3 #ifndef ACE_STRATEGIES_T_CPP
4 #define ACE_STRATEGIES_T_CPP
6 #include "ace/Strategies_T.h"
8 #if !defined (ACE_LACKS_PRAGMA_ONCE)
9 # pragma once
10 #endif /* ACE_LACKS_PRAGMA_ONCE */
12 #include "ace/Service_Repository.h"
13 #include "ace/Service_Types.h"
14 #include "ace/Thread_Manager.h"
15 #include "ace/WFMO_Reactor.h"
16 #include "ace/ACE.h"
17 #include "ace/OS_NS_dlfcn.h"
18 #include "ace/OS_NS_string.h"
19 #include "ace/OS_Errno.h"
20 #include "ace/Svc_Handler.h"
21 #if defined (ACE_OPENVMS)
22 # include "ace/Lib_Find.h"
23 #endif
25 #if !defined (__ACE_INLINE__)
26 #include "ace/Strategies_T.inl"
27 #endif /* __ACE_INLINE__ */
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 template<class SVC_HANDLER>
32 ACE_Recycling_Strategy<SVC_HANDLER>::~ACE_Recycling_Strategy (void)
36 template<class SVC_HANDLER> int
37 ACE_Recycling_Strategy<SVC_HANDLER>::assign_recycler (SVC_HANDLER *svc_handler,
38 ACE_Connection_Recycling_Strategy *recycler,
39 const void *recycling_act)
41 svc_handler->recycler (recycler, recycling_act);
42 return 0;
45 template<class SVC_HANDLER> int
46 ACE_Recycling_Strategy<SVC_HANDLER>::prepare_for_recycling (SVC_HANDLER *svc_handler)
48 return svc_handler->recycle ();
51 template <class SVC_HANDLER>
52 ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy (void)
54 ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy");
55 if (this->delete_svc_handler_)
56 delete this->svc_handler_;
59 // Create a Singleton SVC_HANDLER by always returning the same
60 // SVC_HANDLER.
62 template <class SVC_HANDLER> int
63 ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
65 ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler");
66 sh = this->svc_handler_;
67 return 0;
70 template <class SVC_HANDLER> int
71 ACE_Singleton_Strategy<SVC_HANDLER>::open (SVC_HANDLER *sh,
72 ACE_Thread_Manager *)
74 ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::open");
76 if (this->delete_svc_handler_)
77 delete this->svc_handler_;
79 // If <sh> is NULL then create a new <SVC_HANDLER>.
80 if (sh == 0)
82 ACE_NEW_RETURN (this->svc_handler_,
83 SVC_HANDLER,
84 -1);
85 this->delete_svc_handler_ = true;
87 else
89 this->svc_handler_ = sh;
90 this->delete_svc_handler_ = false;
93 return 0;
96 template <class SVC_HANDLER> int
97 ACE_DLL_Strategy<SVC_HANDLER>::open (const ACE_TCHAR dll_name[],
98 const ACE_TCHAR factory_function[],
99 const ACE_TCHAR svc_name[],
100 ACE_Service_Repository *svc_rep,
101 ACE_Thread_Manager *thr_mgr)
103 ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::open");
104 this->inherited::open (thr_mgr);
105 ACE_OS::strcpy (this->dll_name_, dll_name);
106 ACE_OS::strcpy (this->factory_function_, factory_function);
107 ACE_OS::strcpy (this->svc_name_, svc_name);
108 this->svc_rep_ = svc_rep;
109 return 0;
112 // Create a SVC_HANDLER by dynamically linking it from a DLL.
114 template <class SVC_HANDLER> int
115 ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
117 ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler");
119 // Open the shared library.
120 ACE_SHLIB_HANDLE handle = ACE_OS::dlopen (this->dll_name_);
122 // Extract the factory function.
123 #if defined (ACE_OPENVMS)
124 SVC_HANDLER *(*factory)(void) =
125 (SVC_HANDLER *(*)(void)) ACE::ldsymbol (handle,
126 this->factory_function_);
127 #else
128 SVC_HANDLER *(*factory)(void) =
129 (SVC_HANDLER *(*)(void)) ACE_OS::dlsym (handle,
130 this->factory_function_);
131 #endif
133 // Call the factory function to obtain the new SVC_Handler (should
134 // use RTTI here when it becomes available...)
135 SVC_HANDLER *svc_handler = 0;
137 ACE_ALLOCATOR_RETURN (svc_handler, (*factory)(), -1);
139 if (svc_handler != 0)
141 // Create an ACE_Service_Type containing the SVC_Handler and
142 // insert into this->svc_rep_;
144 ACE_Service_Type_Impl *stp = 0;
145 ACE_NEW_RETURN (stp,
146 ACE_Service_Object_Type (svc_handler,
147 this->svc_name_),
148 -1);
150 ACE_Service_Type *srp = 0;
152 ACE_NEW_RETURN (srp,
153 ACE_Service_Type (this->svc_name_,
154 stp,
155 handle,
157 -1);
158 if (srp == 0)
160 delete stp;
161 errno = ENOMEM;
162 return -1;
165 if (this->svc_rep_->insert (srp) == -1)
166 return -1;
167 // @@ Somehow, we need to deal with this->thr_mgr_...
170 sh = svc_handler;
171 return 0;
174 // Default behavior is to activate the SVC_HANDLER by calling it's
175 // open() method, which allows the SVC_HANDLER to determine its own
176 // concurrency strategy.
178 template <class SVC_HANDLER> int
179 ACE_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
180 void *arg)
182 ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler");
184 int result = 0;
186 // See if we should enable non-blocking I/O on the <svc_handler>'s
187 // peer.
188 if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0)
190 if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1)
191 result = -1;
193 // Otherwise, make sure it's disabled by default.
194 else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1)
195 result = -1;
197 if (result == 0 && svc_handler->open (arg) == -1)
198 result = -1;
200 if (result == -1)
201 // The connection was already made; so this close is a "normal" close
202 // operation.
203 svc_handler->close (NORMAL_CLOSE_OPERATION);
205 return result;
208 template <class SVC_HANDLER> int
209 ACE_Reactive_Strategy<SVC_HANDLER>::open (ACE_Reactor *reactor,
210 ACE_Reactor_Mask mask,
211 int flags)
213 ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::open");
214 this->reactor_ = reactor;
215 this->mask_ = mask;
216 this->flags_ = flags;
218 // Must have a <Reactor>
219 if (this->reactor_ == 0)
220 return -1;
221 else
222 return 0;
225 template <class SVC_HANDLER> int
226 ACE_Reactive_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
227 void *arg)
229 ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::activate_svc_handler");
231 int result = 0;
233 if (this->reactor_ == 0)
234 result = -1;
236 // Register with the Reactor with the appropriate <mask>.
237 else if (this->reactor_->register_handler (svc_handler, this->mask_) == -1)
238 result = -1;
240 // If the implementation of the reactor uses event associations
241 else if (this->reactor_->uses_event_associations ())
243 // If we don't have non-block on, it won't work with
244 // WFMO_Reactor
245 // This maybe too harsh
246 // if (!ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK))
247 // goto failure;
248 if (svc_handler->open (arg) != -1)
249 return 0;
250 else
251 result = -1;
253 else
254 // Call up to our parent to do the SVC_HANDLER initialization.
255 return this->inherited::activate_svc_handler (svc_handler, arg);
257 if (result == -1)
258 // The connection was already made; so this close is a "normal" close
259 // operation.
260 svc_handler->close (NORMAL_CLOSE_OPERATION);
262 return result;
265 template <class SVC_HANDLER> int
266 ACE_Thread_Strategy<SVC_HANDLER>::open (ACE_Thread_Manager *thr_mgr,
267 long thr_flags,
268 int n_threads,
269 int flags)
271 ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::open");
272 this->thr_mgr_ = thr_mgr;
273 this->n_threads_ = n_threads;
274 this->thr_flags_ = thr_flags;
275 this->flags_ = flags;
277 // Must have a thread manager!
278 if (this->thr_mgr_ == 0)
279 ACE_ERROR_RETURN ((LM_ERROR,
280 ACE_TEXT ("error: must have a non-NULL thread manager\n")),
281 -1);
282 else
283 return 0;
286 template <class SVC_HANDLER> int
287 ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
288 void *arg)
290 ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler");
291 // Call up to our parent to do the SVC_HANDLER initialization.
292 if (this->inherited::activate_svc_handler (svc_handler,
293 arg) == -1)
294 return -1;
295 else
296 // Turn the <svc_handler> into an active object (if it isn't
297 // already one as a result of the first activation...)
298 return svc_handler->activate (this->thr_flags_,
299 this->n_threads_);
302 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
303 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
304 (const ACE_PEER_ACCEPTOR_ADDR &local_addr, int reuse_addr)
306 this->reuse_addr_ = reuse_addr;
307 this->peer_acceptor_addr_ = local_addr;
308 if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1)
309 return -1;
311 // Set the peer acceptor's handle into non-blocking mode. This is a
312 // safe-guard against the race condition that can otherwise occur
313 // between the time when <select> indicates that a passive-mode
314 // socket handle is "ready" and when we call <accept>. During this
315 // interval, the client can shutdown the connection, in which case,
316 // the <accept> call can hang!
317 this->peer_acceptor_.enable (ACE_NONBLOCK);
318 return 0;
321 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
322 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy
323 (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
324 int reuse_addr,
325 ACE_Reactor *reactor)
326 : reactor_ (reactor)
328 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy");
330 if (this->open (local_addr, reuse_addr) == -1)
331 ACE_ERROR ((LM_ERROR,
332 ACE_TEXT ("%p\n"),
333 ACE_TEXT ("open")));
336 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
337 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler
338 (SVC_HANDLER *svc_handler)
340 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
342 // Try to find out if the implementation of the reactor that we are
343 // using requires us to reset the event association for the newly
344 // created handle. This is because the newly created handle will
345 // inherit the properties of the listen handle, including its event
346 // associations.
347 int reset_new_handle = this->reactor_->uses_event_associations ();
349 if (this->peer_acceptor_.accept (svc_handler->peer (), // stream
350 0, // remote address
351 0, // timeout
352 1, // restart
353 reset_new_handle // reset new handler
354 ) == -1)
356 // Ensure that errno is preserved in case the svc_handler
357 // close() method resets it
358 ACE_Errno_Guard error(errno);
360 // Close down handler to avoid memory leaks.
361 svc_handler->close (CLOSE_DURING_NEW_CONNECTION);
363 return -1;
365 else
366 return 0;
369 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
370 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
371 (SVC_HANDLER *&sh,
372 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
373 ACE_Time_Value *timeout,
374 const ACE_PEER_CONNECTOR_ADDR &local_addr,
375 int reuse_addr,
376 int flags,
377 int perms)
379 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler");
381 return this->connector_.connect (sh->peer (),
382 remote_addr,
383 timeout,
384 local_addr,
385 reuse_addr,
386 flags,
387 perms);
390 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
391 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
392 (SVC_HANDLER *&sh,
393 SVC_HANDLER *&sh_copy,
394 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
395 ACE_Time_Value *timeout,
396 const ACE_PEER_CONNECTOR_ADDR &local_addr,
397 int reuse_addr,
398 int flags,
399 int perms)
401 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler");
403 int const result =
404 this->connector_.connect (sh->peer (),
405 remote_addr,
406 timeout,
407 local_addr,
408 reuse_addr,
409 flags,
410 perms);
411 sh_copy = sh;
412 return result;
415 template <class SVC_HANDLER> int
416 ACE_Process_Strategy<SVC_HANDLER>::open (size_t n_processes,
417 ACE_Event_Handler *acceptor,
418 ACE_Reactor *reactor,
419 int avoid_zombies)
421 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::open");
422 this->n_processes_ = n_processes;
423 this->acceptor_ = acceptor;
424 this->reactor_ = reactor;
425 this->flags_ = avoid_zombies;
427 return 0;
430 template <class SVC_HANDLER> int
431 ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
432 void *arg)
434 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler");
436 // If <flags_> is non-0 then we won't create zombies.
437 switch (ACE::fork (ACE_TEXT ("child"), this->flags_))
439 case -1:
441 ACE_Errno_Guard error (errno);
442 svc_handler->destroy ();
444 ACE_ERROR_RETURN ((LM_ERROR,
445 ACE_TEXT ("%p\n"),
446 ACE_TEXT ("fork")),
447 -1);
448 /* NOTREACHED */
449 case 0: // In child process.
451 // Close down the SOCK_Acceptor's handle since we don't need to
452 // keep it open.
453 if (this->acceptor_ != 0)
454 // Ignore the return value here...
455 (void) this->reactor_->remove_handler (this->acceptor_,
456 ACE_Event_Handler::ACCEPT_MASK);
458 // Call up to our ancestor in the inheritance to do the
459 // SVC_HANDLER initialization.
460 return this->inherited::activate_svc_handler (svc_handler, arg);
461 /* NOTREACHED */
462 default: // In parent process.
463 // We need to close down the <SVC_HANDLER> here because it's
464 // running in the child.
465 svc_handler->destroy ();
466 return 0;
470 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX>
471 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::ACE_Cached_Connect_Strategy
472 (creation_strategy_type *cre_s,
473 ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
474 ACE_Recycling_Strategy<SVC_HANDLER> *rec_s,
475 MUTEX *lock,
476 bool delete_lock)
477 : lock_ (lock),
478 delete_lock_ (delete_lock),
479 reverse_lock_ (0),
480 creation_strategy_ (0),
481 delete_creation_strategy_ (false),
482 concurrency_strategy_ (0),
483 delete_concurrency_strategy_ (false),
484 recycling_strategy_ (0),
485 delete_recycling_strategy_ (false)
487 // Create a new lock if necessary.
488 if (this->lock_ == 0)
490 ACE_NEW (this->lock_,
491 MUTEX);
493 this->delete_lock_ = true;
496 ACE_NEW (this->reverse_lock_,
497 REVERSE_MUTEX (*this->lock_));
499 if (this->open (cre_s,
500 con_s,
501 rec_s) == -1)
502 ACE_ERROR ((LM_ERROR,
503 ACE_TEXT ("%p\n"),
504 ACE_TEXT ("ACE_Cached_Connect_Strategy::ACE_Cached_Connect_Strategy")));
507 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX>
508 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::~ACE_Cached_Connect_Strategy (void)
510 if (this->delete_lock_)
511 delete this->lock_;
513 delete this->reverse_lock_;
515 if (this->delete_creation_strategy_)
516 delete this->creation_strategy_;
517 this->delete_creation_strategy_ = false;
518 this->creation_strategy_ = 0;
520 if (this->delete_concurrency_strategy_)
521 delete this->concurrency_strategy_;
522 this->delete_concurrency_strategy_ = false;
523 this->concurrency_strategy_ = 0;
525 if (this->delete_recycling_strategy_)
526 delete this->recycling_strategy_;
527 this->delete_recycling_strategy_ = false;
528 this->recycling_strategy_ = 0;
530 // Close down all cached service handlers.
531 CONNECTION_MAP_ENTRY *entry = 0;
532 for (CONNECTION_MAP_ITERATOR iterator (connection_map_);
533 iterator.next (entry);
534 iterator.advance ())
536 entry->int_id_->recycler (0, 0);
537 entry->int_id_->close ();
541 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
542 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::open
543 (creation_strategy_type *cre_s,
544 ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
545 ACE_Recycling_Strategy<SVC_HANDLER> *rec_s)
547 // Initialize the creation strategy.
549 // First we decide if we need to clean up.
550 if (this->creation_strategy_ != 0 &&
551 this->delete_creation_strategy_ &&
552 cre_s != 0)
554 delete this->creation_strategy_;
555 this->creation_strategy_ = 0;
556 this->delete_creation_strategy_ = false;
559 if (cre_s != 0)
560 this->creation_strategy_ = cre_s;
561 else if (this->creation_strategy_ == 0)
563 ACE_NEW_RETURN (this->creation_strategy_,
564 CREATION_STRATEGY, -1);
565 this->delete_creation_strategy_ = true;
568 // Initialize the concurrency strategy.
570 if (this->concurrency_strategy_ != 0 &&
571 this->delete_concurrency_strategy_ &&
572 con_s != 0)
574 delete this->concurrency_strategy_;
575 this->concurrency_strategy_ = 0;
576 this->delete_concurrency_strategy_ = false;
579 if (con_s != 0)
580 this->concurrency_strategy_ = con_s;
581 else if (this->concurrency_strategy_ == 0)
583 ACE_NEW_RETURN (this->concurrency_strategy_,
584 CONCURRENCY_STRATEGY, -1);
585 this->delete_concurrency_strategy_ = true;
588 // Initialize the recycling strategy.
590 if (this->recycling_strategy_ != 0 &&
591 this->delete_recycling_strategy_ &&
592 rec_s != 0)
594 delete this->recycling_strategy_;
595 this->recycling_strategy_ = 0;
596 this->delete_recycling_strategy_ = false;
599 if (rec_s != 0)
600 this->recycling_strategy_ = rec_s;
601 else if (this->recycling_strategy_ == 0)
603 ACE_NEW_RETURN (this->recycling_strategy_,
604 RECYCLING_STRATEGY, -1);
605 this->delete_recycling_strategy_ = true;
608 return 0;
611 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
612 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::make_svc_handler
613 (SVC_HANDLER *&sh)
615 return this->creation_strategy_->make_svc_handler (sh);
618 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
619 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::activate_svc_handler
620 (SVC_HANDLER *svc_handler)
622 return this->concurrency_strategy_->activate_svc_handler (svc_handler);
625 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
626 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::assign_recycler
627 (SVC_HANDLER *svc_handler,
628 ACE_Connection_Recycling_Strategy *recycler,
629 const void *recycling_act)
631 return this->recycling_strategy_->assign_recycler (svc_handler,
632 recycler,
633 recycling_act);
636 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
637 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::prepare_for_recycling
638 (SVC_HANDLER *svc_handler)
640 return this->recycling_strategy_->prepare_for_recycling (svc_handler);
643 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
644 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hint_i
645 (SVC_HANDLER *&sh,
646 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
647 ACE_Time_Value *timeout,
648 const ACE_PEER_CONNECTOR_ADDR &local_addr,
649 int reuse_addr,
650 int flags,
651 int perms,
652 CONNECTION_MAP_ENTRY *&entry,
653 int &found)
655 ACE_UNUSED_ARG (remote_addr);
656 ACE_UNUSED_ARG (timeout);
657 ACE_UNUSED_ARG (local_addr);
658 ACE_UNUSED_ARG (reuse_addr);
659 ACE_UNUSED_ARG (flags);
660 ACE_UNUSED_ARG (perms);
662 found = 0;
664 // Get the recycling act for the svc_handler
665 CONNECTION_MAP_ENTRY *possible_entry = (CONNECTION_MAP_ENTRY *) sh->recycling_act ();
667 // Check to see if the hint svc_handler has been closed down
668 if (possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED)
670 // If close, decrement refcount
671 if (possible_entry->ext_id_.decrement () == 0)
673 // If refcount goes to zero, close down the svc_handler
674 possible_entry->int_id_->recycler (0, 0);
675 possible_entry->int_id_->close ();
676 this->purge_i (possible_entry);
679 // Hint not successful
680 found = 0;
682 // Reset hint
683 sh = 0;
686 // If hint is not closed, see if it is connected to the correct
687 // address and is recyclable
688 else if ((possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
689 possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) &&
690 possible_entry->ext_id_.subject () == remote_addr)
692 // Hint successful
693 found = 1;
695 // Tell the <svc_handler> that it should prepare itself for
696 // being recycled.
697 this->prepare_for_recycling (sh);
699 else
701 // This hint will not be used.
702 possible_entry->ext_id_.decrement ();
704 // Hint not successful
705 found = 0;
707 // If <sh> is not connected to the correct address or is busy,
708 // we will not use it.
709 sh = 0;
712 if (found)
713 entry = possible_entry;
715 return 0;
718 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
719 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_create_svc_handler_i
720 (SVC_HANDLER *&sh,
721 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
722 ACE_Time_Value *timeout,
723 const ACE_PEER_CONNECTOR_ADDR &local_addr,
724 int reuse_addr,
725 int flags,
726 int perms,
727 CONNECTION_MAP_ENTRY *&entry,
728 int &found)
730 // Explicit type conversion
731 REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr);
733 // Try to find the address in the cache. Only if we don't find it
734 // do we create a new <SVC_HANDLER> and connect it with the server.
735 if (this->find (search_addr, entry) == -1)
737 // Set the flag
738 found = 0;
740 // We need to use a temporary variable here since we are not
741 // allowed to change <sh> because other threads may use this
742 // when we let go of the lock during the OS level connect.
744 // Note that making a new svc_handler, connecting remotely,
745 // binding to the map, and assigning of the hint and recycler
746 // should be atomic to the outside world.
747 SVC_HANDLER *potential_handler = 0;
749 // Create a new svc_handler
750 if (this->make_svc_handler (potential_handler) == -1)
751 return -1;
753 // Actively establish the connection. This is a timed blocking
754 // connect.
755 if (this->new_connection (potential_handler,
756 remote_addr,
757 timeout,
758 local_addr,
759 reuse_addr,
760 flags,
761 perms) == -1)
763 // If connect() failed because of timeouts, we have to
764 // reject the connection entirely. This is necessary since
765 // currently there is no way for the non-blocking connects
766 // to complete and for the <Connector> to notify the cache
767 // of the completion of connect().
768 if (errno == EWOULDBLOCK)
769 errno = ENOTSUP;
771 // Close the svc handler.
772 potential_handler->close (0);
774 return -1;
776 else
778 // Insert the new SVC_HANDLER instance into the cache.
779 if (this->connection_map_.bind (search_addr,
780 potential_handler,
781 entry) == -1)
783 // Close the svc handler.
784 potential_handler->close (CLOSE_DURING_NEW_CONNECTION);
786 return -1;
789 // Everything succeeded as planned. Assign <sh> to <potential_handler>.
790 sh = potential_handler;
792 // Set the recycler and the recycling act
793 this->assign_recycler (sh, this, entry);
796 else
797 // We found a cached svc_handler.
799 // Set the flag
800 found = 1;
802 // Get the cached <svc_handler>
803 sh = entry->int_id_;
805 // Tell the <svc_handler> that it should prepare itself for
806 // being recycled.
807 this->prepare_for_recycling (sh);
810 return 0;
813 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
814 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::new_connection
815 (SVC_HANDLER *&sh,
816 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
817 ACE_Time_Value *timeout,
818 const ACE_PEER_CONNECTOR_ADDR &local_addr,
819 int reuse_addr,
820 int flags,
821 int perms)
823 // Yow, Reverse Guard! Let go of the lock for the duration of the
824 // actual connect. This will allow other threads to hack on the
825 // connection cache while this thread creates the new connection.
826 ACE_GUARD_RETURN (REVERSE_MUTEX, ace_mon, *this->reverse_lock_, -1);
828 return this->CONNECT_STRATEGY::connect_svc_handler (sh,
829 remote_addr,
830 timeout,
831 local_addr,
832 reuse_addr,
833 flags,
834 perms);
837 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
838 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler
839 (SVC_HANDLER *&sh,
840 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
841 ACE_Time_Value *timeout,
842 const ACE_PEER_CONNECTOR_ADDR &local_addr,
843 int reuse_addr,
844 int flags,
845 int perms)
847 int found = 0;
849 // This artificial scope is required since we need to let go of the
850 // lock *before* registering the newly created handler with the
851 // Reactor.
853 // Synchronization is required here as the setting of the
854 // recyclable state must be done atomically with the finding and
855 // binding of the service handler in the cache.
856 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
858 int result = this->connect_svc_handler_i (sh,
859 remote_addr,
860 timeout,
861 local_addr,
862 reuse_addr,
863 flags,
864 perms,
865 found);
866 if (result != 0)
867 return result;
871 // If it is a new connection, activate it.
873 // Note: This activation is outside the scope of the lock of the
874 // cached connector. This is necessary to avoid subtle deadlock
875 // conditions with this lock and the Reactor lock.
877 if (!found)
879 if (this->activate_svc_handler (sh) == -1)
881 // If an error occurs while activating the handler, the
882 // <activate_svc_handler> method will close the handler.
883 // This in turn will remove this entry from the internal
884 // table.
886 // Synchronization is required here as the setting of the
887 // handler to zero must be done atomically with the users of
888 // the cache.
889 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
891 // Reset handler.
892 sh = 0;
894 return -1;
898 return 0;
901 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
902 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler
903 (SVC_HANDLER *&sh,
904 SVC_HANDLER *&sh_copy,
905 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
906 ACE_Time_Value *timeout,
907 const ACE_PEER_CONNECTOR_ADDR &local_addr,
908 int reuse_addr,
909 int flags,
910 int perms)
912 int found = 0;
914 // This artificial scope is required since we need to let go of the
915 // lock *before* registering the newly created handler with the
916 // Reactor.
918 // Synchronization is required here as the setting of the
919 // recyclable state must be done atomically with the finding and
920 // binding of the service handler in the cache.
921 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
923 int result = this->connect_svc_handler_i (sh,
924 remote_addr,
925 timeout,
926 local_addr,
927 reuse_addr,
928 flags,
929 perms,
930 found);
931 sh_copy = sh;
933 if (result != 0)
934 return result;
938 // If it is a new connection, activate it.
940 // Note: This activation is outside the scope of the lock of the
941 // cached connector. This is necessary to avoid subtle deadlock
942 // conditions with this lock and the Reactor lock.
944 if (!found)
946 if (this->activate_svc_handler (sh_copy) == -1)
948 // If an error occurs while activating the handler, the
949 // <activate_svc_handler> method will close the handler.
950 // This in turn will remove this entry from the internal
951 // table.
953 // Synchronization is required here as the setting of the
954 // handler to zero must be done atomically with the users of
955 // the cache.
956 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
958 // Reset handler.
959 sh = 0;
960 sh_copy = 0;
962 return -1;
966 return 0;
969 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
970 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler_i
971 (SVC_HANDLER *&sh,
972 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
973 ACE_Time_Value *timeout,
974 const ACE_PEER_CONNECTOR_ADDR &local_addr,
975 int reuse_addr,
976 int flags,
977 int perms,
978 int& found)
980 CONNECTION_MAP_ENTRY *entry = 0;
982 // Check if the user passed a hint svc_handler
983 if (sh != 0)
985 int result = this->check_hint_i (sh,
986 remote_addr,
987 timeout,
988 local_addr,
989 reuse_addr,
990 flags,
991 perms,
992 entry,
993 found);
994 if (result != 0)
995 return result;
998 // If not found
999 if (!found)
1001 int result = this->find_or_create_svc_handler_i (sh,
1002 remote_addr,
1003 timeout,
1004 local_addr,
1005 reuse_addr,
1006 flags,
1007 perms,
1008 entry,
1009 found);
1010 if (result != 0)
1011 return result;
1014 // For all successful cases: mark the <svc_handler> in the cache
1015 // as being <in_use>. Therefore recyclable is BUSY.
1016 entry->ext_id_.recycle_state (ACE_RECYCLABLE_BUSY);
1018 // And increment the refcount
1019 entry->ext_id_.increment ();
1021 return 0;
1024 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1025 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache (const void *recycling_act)
1027 // Synchronization is required here as the setting of the recyclable
1028 // state must be done atomically with respect to other threads that
1029 // are querying the cache.
1030 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1032 return this->cache_i (recycling_act);
1035 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1036 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache_i (const void *recycling_act)
1038 // The wonders and perils of ACT
1039 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1041 // Mark the <svc_handler> in the cache as not being <in_use>.
1042 // Therefore recyclable is IDLE.
1043 entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
1045 return 0;
1048 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1049 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state (const void *recycling_act,
1050 ACE_Recyclable_State new_state)
1052 // Synchronization is required here as the setting of the recyclable
1053 // state must be done atomically with respect to other threads that
1054 // are querying the cache.
1055 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1057 return this->recycle_state_i (recycling_act,
1058 new_state);
1061 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1062 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state_i (const void *recycling_act,
1063 ACE_Recyclable_State new_state)
1065 // The wonders and perils of ACT
1066 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1068 // Mark the <svc_handler> in the cache as not being <in_use>.
1069 // Therefore recyclable is IDLE.
1070 entry->ext_id_.recycle_state (new_state);
1072 return 0;
1075 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recyclable_State
1076 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state (const void *recycling_act) const
1078 // Const cast.
1079 SELF *fake_this = const_cast<SELF *> (this);
1081 // Synchronization is required here.
1082 ACE_GUARD_RETURN (MUTEX, ace_mon, *fake_this->lock_, ACE_RECYCLABLE_UNKNOWN);
1084 return this->recycle_state_i (recycling_act);
1087 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recyclable_State
1088 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state_i (const void *recycling_act) const
1090 // The wonders and perils of ACT
1091 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1093 // Mark the <svc_handler> in the cache as not being <in_use>.
1094 // Therefore recyclable is IDLE.
1095 return entry->ext_id_.recycle_state ();
1098 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1099 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::purge (const void *recycling_act)
1101 // Excluded other threads from changing cache while we take this
1102 // entry out.
1103 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1105 return this->purge_i (recycling_act);
1108 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1109 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::purge_i (const void *recycling_act)
1111 // The wonders and perils of ACT
1112 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1114 return this->connection_map_.unbind (entry);
1117 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1118 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_closed (const void *recycling_act)
1120 // Excluded other threads from changing cache while we take this
1121 // entry out.
1122 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1124 return this->mark_as_closed_i (recycling_act);
1127 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1128 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_closed_i (const void *recycling_act)
1130 // The wonders and perils of ACT
1131 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1133 // Mark the <svc_handler> in the cache as CLOSED.
1134 entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED);
1136 return 0;
1139 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1140 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint (const void *recycling_act,
1141 void **act_holder)
1143 // Excluded other threads from changing cache while we take this
1144 // entry out.
1145 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1147 return this->cleanup_hint_i (recycling_act,
1148 act_holder);
1151 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1152 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint_i (const void *recycling_act,
1153 void **act_holder)
1155 // Reset the <*act_holder> in the confines and protection of the
1156 // lock.
1157 if (act_holder)
1158 *act_holder = 0;
1160 // The wonders and perils of ACT
1161 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1163 // Decrement the refcount on the <svc_handler>.
1164 int refcount = entry->ext_id_.decrement ();
1166 // If the svc_handler state is closed and the refcount == 0, call
1167 // close() on svc_handler.
1168 if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED &&
1169 refcount == 0)
1171 entry->int_id_->recycler (0, 0);
1172 entry->int_id_->close ();
1173 this->purge_i (entry);
1176 return 0;
1179 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Creation_Strategy<SVC_HANDLER> *
1180 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::creation_strategy (void) const
1182 return this->creation_strategy_;
1185 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recycling_Strategy<SVC_HANDLER> *
1186 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycling_strategy (void) const
1188 return this->recycling_strategy_;
1191 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Concurrency_Strategy<SVC_HANDLER> *
1192 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::concurrency_strategy (void) const
1194 return this->concurrency_strategy_;
1197 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1198 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find (
1199 REFCOUNTED_HASH_RECYCLABLE_ADDRESS &search_addr,
1200 CONNECTION_MAP_ENTRY *&entry)
1202 typedef ACE_Hash_Map_Bucket_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
1203 SVC_HANDLER *,
1204 ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
1205 ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
1206 ACE_Null_Mutex>
1207 CONNECTION_MAP_BUCKET_ITERATOR;
1209 CONNECTION_MAP_BUCKET_ITERATOR iterator (this->connection_map_,
1210 search_addr);
1212 CONNECTION_MAP_BUCKET_ITERATOR end (this->connection_map_,
1213 search_addr,
1216 for (;
1217 iterator != end;
1218 ++iterator)
1220 REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_;
1222 if (addr.recycle_state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE &&
1223 addr.recycle_state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE)
1224 continue;
1226 if (addr.subject () != search_addr.subject ())
1227 continue;
1229 entry = &(*iterator);
1230 return 0;
1233 return -1;
1236 template <class SVC_HANDLER> void
1237 ACE_DLL_Strategy<SVC_HANDLER>::dump (void) const
1239 #if defined (ACE_HAS_DUMP)
1240 ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::dump");
1241 #endif /* ACE_HAS_DUMP */
1244 template <class SVC_HANDLER>
1245 ACE_Concurrency_Strategy<SVC_HANDLER>::~ACE_Concurrency_Strategy (void)
1247 ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::~ACE_Concurrency_Strategy");
1251 template <class SVC_HANDLER> void
1252 ACE_Concurrency_Strategy<SVC_HANDLER>::dump (void) const
1254 #if defined (ACE_HAS_DUMP)
1255 ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::dump");
1256 #endif /* ACE_HAS_DUMP */
1259 template <class SVC_HANDLER>
1260 ACE_Reactive_Strategy<SVC_HANDLER>::~ACE_Reactive_Strategy (void)
1262 ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::~ACE_Reactive_Strategy");
1266 template <class SVC_HANDLER> void
1267 ACE_Reactive_Strategy<SVC_HANDLER>::dump (void) const
1269 #if defined (ACE_HAS_DUMP)
1270 ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::dump");
1271 #endif /* ACE_HAS_DUMP */
1274 template <class SVC_HANDLER>
1275 ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy (void)
1277 ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy");
1280 template <class SVC_HANDLER> void
1281 ACE_Thread_Strategy<SVC_HANDLER>::dump (void) const
1283 #if defined (ACE_HAS_DUMP)
1284 ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::dump");
1285 #endif /* ACE_HAS_DUMP */
1288 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
1289 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy (void)
1291 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy");
1293 // Close the underlying acceptor.
1294 this->peer_acceptor_.close ();
1297 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_HANDLE
1298 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle (void) const
1300 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
1301 return this->peer_acceptor_.get_handle ();
1304 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_PEER_ACCEPTOR &
1305 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor (void) const
1307 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
1308 return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
1311 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> void
1312 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump (void) const
1314 #if defined (ACE_HAS_DUMP)
1315 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
1316 #endif /* ACE_HAS_DUMP */
1319 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
1320 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Connect_Strategy (void)
1322 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Connect_Strategy");
1325 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_PEER_CONNECTOR &
1326 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connector (void) const
1328 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connector");
1329 return (ACE_PEER_CONNECTOR &) this->connector_;
1332 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> void
1333 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::dump (void) const
1335 #if defined (ACE_HAS_DUMP)
1336 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::dump");
1337 #endif /* ACE_HAS_DUMP */
1340 template <class SVC_HANDLER>
1341 ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy (void)
1343 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy");
1346 template <class SVC_HANDLER> void
1347 ACE_Process_Strategy<SVC_HANDLER>::dump (void) const
1349 #if defined (ACE_HAS_DUMP)
1350 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::dump");
1351 #endif /* ACE_HAS_DUMP */
1354 template <class SVC_HANDLER>
1355 ACE_Scheduling_Strategy<SVC_HANDLER>::~ACE_Scheduling_Strategy (void)
1357 ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::~ACE_Scheduling_Strategy");
1360 template <class SVC_HANDLER> int
1361 ACE_Scheduling_Strategy<SVC_HANDLER>::suspend (void)
1363 ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::suspend");
1364 return -1;
1367 template <class SVC_HANDLER> int
1368 ACE_Scheduling_Strategy<SVC_HANDLER>::resume (void)
1370 ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::resume");
1371 return -1;
1374 template <class SVC_HANDLER> void
1375 ACE_Scheduling_Strategy<SVC_HANDLER>::dump (void) const
1377 #if defined (ACE_HAS_DUMP)
1378 ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::dump");
1380 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
1381 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
1382 #endif /* ACE_HAS_DUMP */
1385 template <class SVC_HANDLER> int
1386 ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::suspend (void)
1388 ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::suspend");
1389 return this->reactor_->suspend_handlers ();
1392 template <class SVC_HANDLER> int
1393 ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::resume (void)
1395 ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::resume");
1396 return this->reactor_->resume_handlers ();
1399 template <class SVC_HANDLER> void
1400 ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::dump (void) const
1402 #if defined (ACE_HAS_DUMP)
1403 ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::dump");
1405 ACE_Scheduling_Strategy<SVC_HANDLER>::dump ();
1406 #endif /* ACE_HAS_DUMP */
1409 template <class SVC_HANDLER> int
1410 ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::suspend (void)
1412 ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::suspend");
1413 return this->thr_mgr_->suspend_all ();
1416 template <class SVC_HANDLER> int
1417 ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::resume (void)
1419 ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::resume");
1420 return this->thr_mgr_->resume_all ();
1423 template <class SVC_HANDLER> void
1424 ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::dump (void) const
1426 #if defined (ACE_HAS_DUMP)
1427 ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::dump");
1429 ACE_Scheduling_Strategy<SVC_HANDLER>::dump ();
1430 #endif /* ACE_HAS_DUMP */
1433 template <class T>
1434 ACE_Refcounted_Hash_Recyclable<T>::~ACE_Refcounted_Hash_Recyclable (void)
1438 template <class SVC_HANDLER> void
1439 ACE_Singleton_Strategy<SVC_HANDLER>::dump (void) const
1441 #if defined (ACE_HAS_DUMP)
1442 ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::dump");
1443 #endif /* ACE_HAS_DUMP */
1446 template <class SVC_HANDLER>
1447 ACE_Creation_Strategy<SVC_HANDLER>::~ACE_Creation_Strategy (void)
1449 ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::~ACE_Creation_Strategy");
1452 // Default behavior is to make a new SVC_HANDLER, passing in the
1453 // Thread_Manager (if any).
1455 template <class SVC_HANDLER> int
1456 ACE_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
1458 ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::make_svc_handler");
1460 if (sh == 0)
1461 ACE_NEW_RETURN (sh, SVC_HANDLER (this->thr_mgr_), -1);
1462 sh->reactor (this->reactor_);
1463 return 0;
1466 template <class SVC_HANDLER> void
1467 ACE_Creation_Strategy<SVC_HANDLER>::dump (void) const
1469 #if defined (ACE_HAS_DUMP)
1470 ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::dump");
1471 #endif /* ACE_HAS_DUMP */
1474 template <class SVC_HANDLER> int
1475 ACE_NOOP_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&)
1477 ACE_TRACE ("ACE_NOOP_Creation_Strategy<SVC_HANDLER>::make_svc_handler");
1478 return 0;
1481 template <class SVC_HANDLER> int
1482 ACE_NOOP_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *,
1483 void *)
1485 ACE_TRACE ("ACE_NOOP_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler");
1486 return 0;
1490 ACE_ALLOC_HOOK_DEFINE(ACE_Creation_Strategy)
1491 ACE_ALLOC_HOOK_DEFINE(ACE_Singleton_Strategy)
1492 ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Strategy)
1493 ACE_ALLOC_HOOK_DEFINE(ACE_Concurrency_Strategy)
1494 ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy)
1495 ACE_ALLOC_HOOK_DEFINE(ACE_Connect_Strategy)
1496 ACE_ALLOC_HOOK_DEFINE(ACE_Process_Strategy)
1497 ACE_ALLOC_HOOK_DEFINE(ACE_Accept_Strategy)
1498 ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy)
1500 ACE_END_VERSIONED_NAMESPACE_DECL
1502 #endif /* ACE_STRATEGIES_T_CPP */