Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Strategies_T.cpp
blob3ae02a406eb8944457f36ece096c8bdfd1e33c3c
1 #ifndef ACE_STRATEGIES_T_CPP
2 #define ACE_STRATEGIES_T_CPP
4 #include "ace/Strategies_T.h"
6 #if !defined (ACE_LACKS_PRAGMA_ONCE)
7 # pragma once
8 #endif /* ACE_LACKS_PRAGMA_ONCE */
10 #include "ace/Service_Repository.h"
11 #include "ace/Service_Types.h"
12 #include "ace/Thread_Manager.h"
13 #include "ace/WFMO_Reactor.h"
14 #include "ace/ACE.h"
15 #include "ace/OS_NS_dlfcn.h"
16 #include "ace/OS_NS_string.h"
17 #include "ace/OS_Errno.h"
18 #include "ace/Svc_Handler.h"
20 #if !defined (__ACE_INLINE__)
21 #include "ace/Strategies_T.inl"
22 #endif /* __ACE_INLINE__ */
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 template<class SVC_HANDLER>
27 ACE_Recycling_Strategy<SVC_HANDLER>::~ACE_Recycling_Strategy ()
31 template<class SVC_HANDLER> int
32 ACE_Recycling_Strategy<SVC_HANDLER>::assign_recycler (SVC_HANDLER *svc_handler,
33 ACE_Connection_Recycling_Strategy *recycler,
34 const void *recycling_act)
36 svc_handler->recycler (recycler, recycling_act);
37 return 0;
40 template<class SVC_HANDLER> int
41 ACE_Recycling_Strategy<SVC_HANDLER>::prepare_for_recycling (SVC_HANDLER *svc_handler)
43 return svc_handler->recycle ();
46 template <class SVC_HANDLER>
47 ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy ()
49 ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy");
50 if (this->delete_svc_handler_)
51 delete this->svc_handler_;
54 // Create a Singleton SVC_HANDLER by always returning the same
55 // SVC_HANDLER.
57 template <class SVC_HANDLER> int
58 ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
60 ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler");
61 sh = this->svc_handler_;
62 return 0;
65 template <class SVC_HANDLER> int
66 ACE_Singleton_Strategy<SVC_HANDLER>::open (SVC_HANDLER *sh,
67 ACE_Thread_Manager *)
69 ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::open");
71 if (this->delete_svc_handler_)
72 delete this->svc_handler_;
74 // If <sh> is NULL then create a new <SVC_HANDLER>.
75 if (sh == 0)
77 ACE_NEW_RETURN (this->svc_handler_,
78 SVC_HANDLER,
79 -1);
80 this->delete_svc_handler_ = true;
82 else
84 this->svc_handler_ = sh;
85 this->delete_svc_handler_ = false;
88 return 0;
91 template <class SVC_HANDLER> int
92 ACE_DLL_Strategy<SVC_HANDLER>::open (const ACE_TCHAR dll_name[],
93 const ACE_TCHAR factory_function[],
94 const ACE_TCHAR svc_name[],
95 ACE_Service_Repository *svc_rep,
96 ACE_Thread_Manager *thr_mgr)
98 ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::open");
99 this->inherited::open (thr_mgr);
100 ACE_OS::strcpy (this->dll_name_, dll_name);
101 ACE_OS::strcpy (this->factory_function_, factory_function);
102 ACE_OS::strcpy (this->svc_name_, svc_name);
103 this->svc_rep_ = svc_rep;
104 return 0;
107 // Create a SVC_HANDLER by dynamically linking it from a DLL.
109 template <class SVC_HANDLER> int
110 ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
112 ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler");
114 // Open the shared library.
115 ACE_SHLIB_HANDLE handle = ACE_OS::dlopen (this->dll_name_);
117 // Extract the factory function.
118 SVC_HANDLER *(*factory)(void) =
119 (SVC_HANDLER *(*)(void)) ACE_OS::dlsym (handle, this->factory_function_);
121 // Call the factory function to obtain the new SVC_Handler (should
122 // use RTTI here when it becomes available...)
123 SVC_HANDLER *svc_handler = 0;
125 ACE_ALLOCATOR_RETURN (svc_handler, (*factory)(), -1);
127 if (svc_handler != 0)
129 // Create an ACE_Service_Type containing the SVC_Handler and
130 // insert into this->svc_rep_;
132 ACE_Service_Type_Impl *stp = 0;
133 ACE_NEW_RETURN (stp,
134 ACE_Service_Object_Type (svc_handler,
135 this->svc_name_),
136 -1);
138 ACE_Service_Type *srp = 0;
140 ACE_NEW_RETURN (srp,
141 ACE_Service_Type (this->svc_name_,
142 stp,
143 handle,
145 -1);
146 if (srp == 0)
148 delete stp;
149 errno = ENOMEM;
150 return -1;
153 if (this->svc_rep_->insert (srp) == -1)
154 return -1;
155 // @@ Somehow, we need to deal with this->thr_mgr_...
158 sh = svc_handler;
159 return 0;
162 // Default behavior is to activate the SVC_HANDLER by calling it's
163 // open() method, which allows the SVC_HANDLER to determine its own
164 // concurrency strategy.
166 template <class SVC_HANDLER> int
167 ACE_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
168 void *arg)
170 ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler");
172 int result = 0;
174 // See if we should enable non-blocking I/O on the <svc_handler>'s
175 // peer.
176 if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0)
178 if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1)
179 result = -1;
181 // Otherwise, make sure it's disabled by default.
182 else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1)
183 result = -1;
185 if (result == 0 && svc_handler->open (arg) == -1)
186 result = -1;
188 if (result == -1)
189 // The connection was already made; so this close is a "normal" close
190 // operation.
191 svc_handler->close (NORMAL_CLOSE_OPERATION);
193 return result;
196 template <class SVC_HANDLER> int
197 ACE_Reactive_Strategy<SVC_HANDLER>::open (ACE_Reactor *reactor,
198 ACE_Reactor_Mask mask,
199 int flags)
201 ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::open");
202 this->reactor_ = reactor;
203 this->mask_ = mask;
204 this->flags_ = flags;
206 // Must have a <Reactor>
207 if (this->reactor_ == 0)
208 return -1;
209 else
210 return 0;
213 template <class SVC_HANDLER> int
214 ACE_Reactive_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
215 void *arg)
217 ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::activate_svc_handler");
219 int result = 0;
221 if (this->reactor_ == 0)
222 result = -1;
224 // Register with the Reactor with the appropriate <mask>.
225 else if (this->reactor_->register_handler (svc_handler, this->mask_) == -1)
226 result = -1;
228 // If the implementation of the reactor uses event associations
229 else if (this->reactor_->uses_event_associations ())
231 // If we don't have non-block on, it won't work with
232 // WFMO_Reactor
233 // This maybe too harsh
234 // if (!ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK))
235 // goto failure;
236 if (svc_handler->open (arg) != -1)
237 return 0;
238 else
239 result = -1;
241 else
242 // Call up to our parent to do the SVC_HANDLER initialization.
243 return this->inherited::activate_svc_handler (svc_handler, arg);
245 if (result == -1)
246 // The connection was already made; so this close is a "normal" close
247 // operation.
248 svc_handler->close (NORMAL_CLOSE_OPERATION);
250 return result;
253 template <class SVC_HANDLER> int
254 ACE_Thread_Strategy<SVC_HANDLER>::open (ACE_Thread_Manager *thr_mgr,
255 long thr_flags,
256 int n_threads,
257 int flags)
259 ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::open");
260 this->thr_mgr_ = thr_mgr;
261 this->n_threads_ = n_threads;
262 this->thr_flags_ = thr_flags;
263 this->flags_ = flags;
265 // Must have a thread manager!
266 if (this->thr_mgr_ == 0)
267 ACELIB_ERROR_RETURN ((LM_ERROR,
268 ACE_TEXT ("error: must have a non-NULL thread manager\n")),
269 -1);
270 else
271 return 0;
274 template <class SVC_HANDLER> int
275 ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
276 void *arg)
278 ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler");
279 // Call up to our parent to do the SVC_HANDLER initialization.
280 if (this->inherited::activate_svc_handler (svc_handler,
281 arg) == -1)
282 return -1;
283 else
284 // Turn the <svc_handler> into an active object (if it isn't
285 // already one as a result of the first activation...)
286 return svc_handler->activate (this->thr_flags_,
287 this->n_threads_);
290 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
291 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
292 (const ACE_PEER_ACCEPTOR_ADDR &local_addr, bool reuse_addr)
294 this->reuse_addr_ = reuse_addr;
295 this->peer_acceptor_addr_ = local_addr;
296 if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1)
297 return -1;
299 // Set the peer acceptor's handle into non-blocking mode. This is a
300 // safe-guard against the race condition that can otherwise occur
301 // between the time when <select> indicates that a passive-mode
302 // socket handle is "ready" and when we call <accept>. During this
303 // interval, the client can shutdown the connection, in which case,
304 // the <accept> call can hang!
305 if (this->peer_acceptor_.enable (ACE_NONBLOCK) == -1)
306 return -1;
308 return 0;
311 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
312 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy
313 (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
314 bool reuse_addr,
315 ACE_Reactor *reactor)
316 : reactor_ (reactor)
318 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy");
320 if (this->open (local_addr, reuse_addr) == -1)
321 ACELIB_ERROR ((LM_ERROR,
322 ACE_TEXT ("%p\n"),
323 ACE_TEXT ("open")));
326 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
327 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler
328 (SVC_HANDLER *svc_handler)
330 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
332 // Try to find out if the implementation of the reactor that we are
333 // using requires us to reset the event association for the newly
334 // created handle. This is because the newly created handle will
335 // inherit the properties of the listen handle, including its event
336 // associations.
337 bool reset_new_handle = this->reactor_->uses_event_associations ();
339 if (this->peer_acceptor_.accept (svc_handler->peer (), // stream
340 0, // remote address
341 0, // timeout
342 1, // restart
343 reset_new_handle // reset new handler
344 ) == -1)
346 // Ensure that errno is preserved in case the svc_handler
347 // close() method resets it
348 ACE_Errno_Guard error(errno);
350 // Close down handler to avoid memory leaks.
351 svc_handler->close (CLOSE_DURING_NEW_CONNECTION);
353 return -1;
355 else
356 return 0;
359 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
360 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
361 (SVC_HANDLER *&sh,
362 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
363 ACE_Time_Value *timeout,
364 const ACE_PEER_CONNECTOR_ADDR &local_addr,
365 bool reuse_addr,
366 int flags,
367 int perms)
369 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler");
371 return this->connector_.connect (sh->peer (),
372 remote_addr,
373 timeout,
374 local_addr,
375 reuse_addr,
376 flags,
377 perms);
380 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int
381 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler
382 (SVC_HANDLER *&sh,
383 SVC_HANDLER *&sh_copy,
384 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
385 ACE_Time_Value *timeout,
386 const ACE_PEER_CONNECTOR_ADDR &local_addr,
387 bool reuse_addr,
388 int flags,
389 int perms)
391 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler");
393 int const result =
394 this->connector_.connect (sh->peer (),
395 remote_addr,
396 timeout,
397 local_addr,
398 reuse_addr,
399 flags,
400 perms);
401 sh_copy = sh;
402 return result;
405 template <class SVC_HANDLER> int
406 ACE_Process_Strategy<SVC_HANDLER>::open (size_t n_processes,
407 ACE_Event_Handler *acceptor,
408 ACE_Reactor *reactor,
409 int avoid_zombies)
411 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::open");
412 this->n_processes_ = n_processes;
413 this->acceptor_ = acceptor;
414 this->reactor_ = reactor;
415 this->flags_ = avoid_zombies;
417 return 0;
420 template <class SVC_HANDLER> int
421 ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
422 void *arg)
424 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler");
426 // If <flags_> is non-0 then we won't create zombies.
427 switch (ACE::fork (ACE_TEXT ("child"), this->flags_))
429 case static_cast<pid_t>(-1):
431 ACE_Errno_Guard error (errno);
432 svc_handler->close ();
434 ACELIB_ERROR_RETURN ((LM_ERROR,
435 ACE_TEXT ("%p\n"),
436 ACE_TEXT ("fork")),
437 -1);
438 /* NOTREACHED */
439 case 0: // In child process.
441 // Close down the SOCK_Acceptor's handle since we don't need to
442 // keep it open.
443 if (this->acceptor_ != 0)
444 // Ignore the return value here...
445 (void) this->reactor_->remove_handler (this->acceptor_,
446 ACE_Event_Handler::ACCEPT_MASK);
448 // Call up to our ancestor in the inheritance to do the
449 // SVC_HANDLER initialization.
450 return this->inherited::activate_svc_handler (svc_handler, arg);
451 /* NOTREACHED */
452 default: // In parent process.
453 // We need to close down the <SVC_HANDLER> here because it's
454 // running in the child.
455 svc_handler->close ();
456 return 0;
460 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX>
461 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::ACE_Cached_Connect_Strategy
462 (creation_strategy_type *cre_s,
463 ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
464 ACE_Recycling_Strategy<SVC_HANDLER> *rec_s,
465 MUTEX *lock,
466 bool delete_lock)
467 : lock_ (lock),
468 delete_lock_ (delete_lock),
469 reverse_lock_ (0),
470 creation_strategy_ (0),
471 delete_creation_strategy_ (false),
472 concurrency_strategy_ (0),
473 delete_concurrency_strategy_ (false),
474 recycling_strategy_ (0),
475 delete_recycling_strategy_ (false)
477 // Create a new lock if necessary.
478 if (this->lock_ == 0)
480 ACE_NEW (this->lock_,
481 MUTEX);
483 this->delete_lock_ = true;
486 ACE_NEW (this->reverse_lock_,
487 REVERSE_MUTEX (*this->lock_));
489 if (this->open (cre_s,
490 con_s,
491 rec_s) == -1)
492 ACELIB_ERROR ((LM_ERROR,
493 ACE_TEXT ("%p\n"),
494 ACE_TEXT ("ACE_Cached_Connect_Strategy::ACE_Cached_Connect_Strategy")));
497 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX>
498 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::~ACE_Cached_Connect_Strategy ()
500 if (this->delete_lock_)
501 delete this->lock_;
503 delete this->reverse_lock_;
505 if (this->delete_creation_strategy_)
506 delete this->creation_strategy_;
507 this->delete_creation_strategy_ = false;
508 this->creation_strategy_ = 0;
510 if (this->delete_concurrency_strategy_)
511 delete this->concurrency_strategy_;
512 this->delete_concurrency_strategy_ = false;
513 this->concurrency_strategy_ = 0;
515 if (this->delete_recycling_strategy_)
516 delete this->recycling_strategy_;
517 this->delete_recycling_strategy_ = false;
518 this->recycling_strategy_ = 0;
520 // Close down all cached service handlers.
521 CONNECTION_MAP_ENTRY *entry = 0;
522 for (CONNECTION_MAP_ITERATOR iterator (connection_map_);
523 iterator.next (entry);
524 iterator.advance ())
526 entry->int_id_->recycler (0, 0);
527 entry->int_id_->close ();
531 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
532 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::open
533 (creation_strategy_type *cre_s,
534 ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
535 ACE_Recycling_Strategy<SVC_HANDLER> *rec_s)
537 // Initialize the creation strategy.
539 // First we decide if we need to clean up.
540 if (this->creation_strategy_ != 0 &&
541 this->delete_creation_strategy_ &&
542 cre_s != 0)
544 delete this->creation_strategy_;
545 this->creation_strategy_ = 0;
546 this->delete_creation_strategy_ = false;
549 if (cre_s != 0)
550 this->creation_strategy_ = cre_s;
551 else if (this->creation_strategy_ == 0)
553 ACE_NEW_RETURN (this->creation_strategy_,
554 CREATION_STRATEGY, -1);
555 this->delete_creation_strategy_ = true;
558 // Initialize the concurrency strategy.
560 if (this->concurrency_strategy_ != 0 &&
561 this->delete_concurrency_strategy_ &&
562 con_s != 0)
564 delete this->concurrency_strategy_;
565 this->concurrency_strategy_ = 0;
566 this->delete_concurrency_strategy_ = false;
569 if (con_s != 0)
570 this->concurrency_strategy_ = con_s;
571 else if (this->concurrency_strategy_ == 0)
573 ACE_NEW_RETURN (this->concurrency_strategy_,
574 CONCURRENCY_STRATEGY, -1);
575 this->delete_concurrency_strategy_ = true;
578 // Initialize the recycling strategy.
580 if (this->recycling_strategy_ != 0 &&
581 this->delete_recycling_strategy_ &&
582 rec_s != 0)
584 delete this->recycling_strategy_;
585 this->recycling_strategy_ = 0;
586 this->delete_recycling_strategy_ = false;
589 if (rec_s != 0)
590 this->recycling_strategy_ = rec_s;
591 else if (this->recycling_strategy_ == 0)
593 ACE_NEW_RETURN (this->recycling_strategy_,
594 RECYCLING_STRATEGY, -1);
595 this->delete_recycling_strategy_ = true;
598 return 0;
601 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
602 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::make_svc_handler
603 (SVC_HANDLER *&sh)
605 return this->creation_strategy_->make_svc_handler (sh);
608 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
609 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::activate_svc_handler
610 (SVC_HANDLER *svc_handler)
612 return this->concurrency_strategy_->activate_svc_handler (svc_handler);
615 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
616 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::assign_recycler
617 (SVC_HANDLER *svc_handler,
618 ACE_Connection_Recycling_Strategy *recycler,
619 const void *recycling_act)
621 return this->recycling_strategy_->assign_recycler (svc_handler,
622 recycler,
623 recycling_act);
626 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
627 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::prepare_for_recycling
628 (SVC_HANDLER *svc_handler)
630 return this->recycling_strategy_->prepare_for_recycling (svc_handler);
633 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
634 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hint_i
635 (SVC_HANDLER *&sh,
636 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
637 ACE_Time_Value *timeout,
638 const ACE_PEER_CONNECTOR_ADDR &local_addr,
639 bool reuse_addr,
640 int flags,
641 int perms,
642 CONNECTION_MAP_ENTRY *&entry,
643 int &found)
645 ACE_UNUSED_ARG (remote_addr);
646 ACE_UNUSED_ARG (timeout);
647 ACE_UNUSED_ARG (local_addr);
648 ACE_UNUSED_ARG (reuse_addr);
649 ACE_UNUSED_ARG (flags);
650 ACE_UNUSED_ARG (perms);
652 found = 0;
654 // Get the recycling act for the svc_handler
655 CONNECTION_MAP_ENTRY *possible_entry = (CONNECTION_MAP_ENTRY *) sh->recycling_act ();
657 // Check to see if the hint svc_handler has been closed down
658 if (possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED)
660 // If close, decrement refcount
661 if (possible_entry->ext_id_.decrement () == 0)
663 // If refcount goes to zero, close down the svc_handler
664 possible_entry->int_id_->recycler (0, 0);
665 possible_entry->int_id_->close ();
666 this->purge_i (possible_entry);
669 // Hint not successful
670 found = 0;
672 // Reset hint
673 sh = 0;
676 // If hint is not closed, see if it is connected to the correct
677 // address and is recyclable
678 else if ((possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
679 possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) &&
680 possible_entry->ext_id_.subject () == remote_addr)
682 // Hint successful
683 found = 1;
685 // Tell the <svc_handler> that it should prepare itself for
686 // being recycled.
687 this->prepare_for_recycling (sh);
689 else
691 // This hint will not be used.
692 possible_entry->ext_id_.decrement ();
694 // Hint not successful
695 found = 0;
697 // If <sh> is not connected to the correct address or is busy,
698 // we will not use it.
699 sh = 0;
702 if (found)
703 entry = possible_entry;
705 return 0;
708 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
709 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_create_svc_handler_i
710 (SVC_HANDLER *&sh,
711 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
712 ACE_Time_Value *timeout,
713 const ACE_PEER_CONNECTOR_ADDR &local_addr,
714 bool reuse_addr,
715 int flags,
716 int perms,
717 CONNECTION_MAP_ENTRY *&entry,
718 int &found)
720 // Explicit type conversion
721 REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr);
723 // Try to find the address in the cache. Only if we don't find it
724 // do we create a new <SVC_HANDLER> and connect it with the server.
725 if (this->find (search_addr, entry) == -1)
727 // Set the flag
728 found = 0;
730 // We need to use a temporary variable here since we are not
731 // allowed to change <sh> because other threads may use this
732 // when we let go of the lock during the OS level connect.
734 // Note that making a new svc_handler, connecting remotely,
735 // binding to the map, and assigning of the hint and recycler
736 // should be atomic to the outside world.
737 SVC_HANDLER *potential_handler = 0;
739 // Create a new svc_handler
740 if (this->make_svc_handler (potential_handler) == -1)
741 return -1;
743 // Actively establish the connection. This is a timed blocking
744 // connect.
745 if (this->new_connection (potential_handler,
746 remote_addr,
747 timeout,
748 local_addr,
749 reuse_addr,
750 flags,
751 perms) == -1)
753 // If connect() failed because of timeouts, we have to
754 // reject the connection entirely. This is necessary since
755 // currently there is no way for the non-blocking connects
756 // to complete and for the <Connector> to notify the cache
757 // of the completion of connect().
758 if (errno == EWOULDBLOCK)
759 errno = ENOTSUP;
761 // Close the svc handler.
762 potential_handler->close (0);
764 return -1;
766 else
768 // Insert the new SVC_HANDLER instance into the cache.
769 if (this->connection_map_.bind (search_addr,
770 potential_handler,
771 entry) == -1)
773 // Close the svc handler.
774 potential_handler->close (CLOSE_DURING_NEW_CONNECTION);
776 return -1;
779 // Everything succeeded as planned. Assign <sh> to <potential_handler>.
780 sh = potential_handler;
782 // Set the recycler and the recycling act
783 this->assign_recycler (sh, this, entry);
786 else
787 // We found a cached svc_handler.
789 // Set the flag
790 found = 1;
792 // Get the cached <svc_handler>
793 sh = entry->int_id_;
795 // Tell the <svc_handler> that it should prepare itself for
796 // being recycled.
797 this->prepare_for_recycling (sh);
800 return 0;
803 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
804 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::new_connection
805 (SVC_HANDLER *&sh,
806 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
807 ACE_Time_Value *timeout,
808 const ACE_PEER_CONNECTOR_ADDR &local_addr,
809 bool reuse_addr,
810 int flags,
811 int perms)
813 // Yow, Reverse Guard! Let go of the lock for the duration of the
814 // actual connect. This will allow other threads to hack on the
815 // connection cache while this thread creates the new connection.
816 ACE_GUARD_RETURN (REVERSE_MUTEX, ace_mon, *this->reverse_lock_, -1);
818 return this->CONNECT_STRATEGY::connect_svc_handler (sh,
819 remote_addr,
820 timeout,
821 local_addr,
822 reuse_addr,
823 flags,
824 perms);
827 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
828 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler
829 (SVC_HANDLER *&sh,
830 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
831 ACE_Time_Value *timeout,
832 const ACE_PEER_CONNECTOR_ADDR &local_addr,
833 bool reuse_addr,
834 int flags,
835 int perms)
837 int found = 0;
839 // This artificial scope is required since we need to let go of the
840 // lock *before* registering the newly created handler with the
841 // Reactor.
843 // Synchronization is required here as the setting of the
844 // recyclable state must be done atomically with the finding and
845 // binding of the service handler in the cache.
846 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
848 int result = this->connect_svc_handler_i (sh,
849 remote_addr,
850 timeout,
851 local_addr,
852 reuse_addr,
853 flags,
854 perms,
855 found);
856 if (result != 0)
857 return result;
860 // If it is a new connection, activate it.
862 // Note: This activation is outside the scope of the lock of the
863 // cached connector. This is necessary to avoid subtle deadlock
864 // conditions with this lock and the Reactor lock.
866 if (!found)
868 if (this->activate_svc_handler (sh) == -1)
870 // If an error occurs while activating the handler, the
871 // <activate_svc_handler> method will close the handler.
872 // This in turn will remove this entry from the internal
873 // table.
875 // Synchronization is required here as the setting of the
876 // handler to zero must be done atomically with the users of
877 // the cache.
878 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
880 // Reset handler.
881 sh = 0;
883 return -1;
887 return 0;
890 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
891 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler
892 (SVC_HANDLER *&sh,
893 SVC_HANDLER *&sh_copy,
894 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
895 ACE_Time_Value *timeout,
896 const ACE_PEER_CONNECTOR_ADDR &local_addr,
897 bool reuse_addr,
898 int flags,
899 int perms)
901 int found = 0;
903 // This artificial scope is required since we need to let go of the
904 // lock *before* registering the newly created handler with the
905 // Reactor.
907 // Synchronization is required here as the setting of the
908 // recyclable state must be done atomically with the finding and
909 // binding of the service handler in the cache.
910 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
912 int result = this->connect_svc_handler_i (sh,
913 remote_addr,
914 timeout,
915 local_addr,
916 reuse_addr,
917 flags,
918 perms,
919 found);
920 sh_copy = sh;
922 if (result != 0)
923 return result;
926 // If it is a new connection, activate it.
928 // Note: This activation is outside the scope of the lock of the
929 // cached connector. This is necessary to avoid subtle deadlock
930 // conditions with this lock and the Reactor lock.
932 if (!found)
934 if (this->activate_svc_handler (sh_copy) == -1)
936 // If an error occurs while activating the handler, the
937 // <activate_svc_handler> method will close the handler.
938 // This in turn will remove this entry from the internal
939 // table.
941 // Synchronization is required here as the setting of the
942 // handler to zero must be done atomically with the users of
943 // the cache.
944 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
946 // Reset handler.
947 sh = 0;
948 sh_copy = 0;
950 return -1;
954 return 0;
957 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
958 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler_i
959 (SVC_HANDLER *&sh,
960 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
961 ACE_Time_Value *timeout,
962 const ACE_PEER_CONNECTOR_ADDR &local_addr,
963 bool reuse_addr,
964 int flags,
965 int perms,
966 int& found)
968 CONNECTION_MAP_ENTRY *entry = 0;
970 // Check if the user passed a hint svc_handler
971 if (sh != 0)
973 int result = this->check_hint_i (sh,
974 remote_addr,
975 timeout,
976 local_addr,
977 reuse_addr,
978 flags,
979 perms,
980 entry,
981 found);
982 if (result != 0)
983 return result;
986 // If not found
987 if (!found)
989 int result = this->find_or_create_svc_handler_i (sh,
990 remote_addr,
991 timeout,
992 local_addr,
993 reuse_addr,
994 flags,
995 perms,
996 entry,
997 found);
998 if (result != 0)
999 return result;
1002 if (entry)
1004 // For all successful cases: mark the <svc_handler> in the cache
1005 // as being <in_use>. Therefore recyclable is BUSY.
1006 entry->ext_id_.recycle_state (ACE_RECYCLABLE_BUSY);
1008 // And increment the refcount
1009 entry->ext_id_.increment ();
1012 return 0;
1015 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1016 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache (const void *recycling_act)
1018 // Synchronization is required here as the setting of the recyclable
1019 // state must be done atomically with respect to other threads that
1020 // are querying the cache.
1021 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1023 return this->cache_i (recycling_act);
1026 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1027 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache_i (const void *recycling_act)
1029 // The wonders and perils of ACT
1030 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1032 // Mark the <svc_handler> in the cache as not being <in_use>.
1033 // Therefore recyclable is IDLE.
1034 entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
1036 return 0;
1039 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1040 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state (const void *recycling_act,
1041 ACE_Recyclable_State new_state)
1043 // Synchronization is required here as the setting of the recyclable
1044 // state must be done atomically with respect to other threads that
1045 // are querying the cache.
1046 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1048 return this->recycle_state_i (recycling_act,
1049 new_state);
1052 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1053 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state_i (const void *recycling_act,
1054 ACE_Recyclable_State new_state)
1056 // The wonders and perils of ACT
1057 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1059 // Mark the <svc_handler> in the cache as not being <in_use>.
1060 // Therefore recyclable is IDLE.
1061 entry->ext_id_.recycle_state (new_state);
1063 return 0;
1066 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recyclable_State
1067 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state (const void *recycling_act) const
1069 // Const cast.
1070 SELF *fake_this = const_cast<SELF *> (this);
1072 // Synchronization is required here.
1073 ACE_GUARD_RETURN (MUTEX, ace_mon, *fake_this->lock_, ACE_RECYCLABLE_UNKNOWN);
1075 return this->recycle_state_i (recycling_act);
1078 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recyclable_State
1079 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state_i (const void *recycling_act) const
1081 // The wonders and perils of ACT
1082 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1084 // Mark the <svc_handler> in the cache as not being <in_use>.
1085 // Therefore recyclable is IDLE.
1086 return entry->ext_id_.recycle_state ();
1089 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1090 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::purge (const void *recycling_act)
1092 // Excluded other threads from changing cache while we take this
1093 // entry out.
1094 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1096 return this->purge_i (recycling_act);
1099 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1100 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::purge_i (const void *recycling_act)
1102 // The wonders and perils of ACT
1103 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1105 return this->connection_map_.unbind (entry);
1108 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1109 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_closed (const void *recycling_act)
1111 // Excluded other threads from changing cache while we take this
1112 // entry out.
1113 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1115 return this->mark_as_closed_i (recycling_act);
1118 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1119 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_closed_i (const void *recycling_act)
1121 // The wonders and perils of ACT
1122 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1124 // Mark the <svc_handler> in the cache as CLOSED.
1125 entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED);
1127 return 0;
1130 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1131 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint (const void *recycling_act,
1132 void **act_holder)
1134 // Excluded other threads from changing cache while we take this
1135 // entry out.
1136 ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
1138 return this->cleanup_hint_i (recycling_act,
1139 act_holder);
1142 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1143 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint_i (const void *recycling_act,
1144 void **act_holder)
1146 // Reset the <*act_holder> in the confines and protection of the
1147 // lock.
1148 if (act_holder)
1149 *act_holder = 0;
1151 // The wonders and perils of ACT
1152 CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
1154 // Decrement the refcount on the <svc_handler>.
1155 int refcount = entry->ext_id_.decrement ();
1157 // If the svc_handler state is closed and the refcount == 0, call
1158 // close() on svc_handler.
1159 if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED &&
1160 refcount == 0)
1162 entry->int_id_->recycler (0, 0);
1163 entry->int_id_->close ();
1164 this->purge_i (entry);
1167 return 0;
1170 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Creation_Strategy<SVC_HANDLER> *
1171 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::creation_strategy () const
1173 return this->creation_strategy_;
1176 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recycling_Strategy<SVC_HANDLER> *
1177 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycling_strategy () const
1179 return this->recycling_strategy_;
1182 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Concurrency_Strategy<SVC_HANDLER> *
1183 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::concurrency_strategy () const
1185 return this->concurrency_strategy_;
1188 template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
1189 ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find (
1190 REFCOUNTED_HASH_RECYCLABLE_ADDRESS &search_addr,
1191 CONNECTION_MAP_ENTRY *&entry)
1193 typedef ACE_Hash_Map_Bucket_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
1194 SVC_HANDLER *,
1195 ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
1196 ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
1197 ACE_Null_Mutex>
1198 CONNECTION_MAP_BUCKET_ITERATOR;
1200 CONNECTION_MAP_BUCKET_ITERATOR iterator (this->connection_map_,
1201 search_addr);
1203 CONNECTION_MAP_BUCKET_ITERATOR end (this->connection_map_,
1204 search_addr,
1207 for (;
1208 iterator != end;
1209 ++iterator)
1211 REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_;
1213 if (addr.recycle_state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE &&
1214 addr.recycle_state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE)
1215 continue;
1217 if (addr.subject () != search_addr.subject ())
1218 continue;
1220 entry = &(*iterator);
1221 return 0;
1224 return -1;
1227 template <class SVC_HANDLER> void
1228 ACE_DLL_Strategy<SVC_HANDLER>::dump () const
1230 #if defined (ACE_HAS_DUMP)
1231 ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::dump");
1232 #endif /* ACE_HAS_DUMP */
1235 template <class SVC_HANDLER>
1236 ACE_Concurrency_Strategy<SVC_HANDLER>::~ACE_Concurrency_Strategy ()
1238 ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::~ACE_Concurrency_Strategy");
1242 template <class SVC_HANDLER> void
1243 ACE_Concurrency_Strategy<SVC_HANDLER>::dump () const
1245 #if defined (ACE_HAS_DUMP)
1246 ACE_TRACE ("ACE_Concurrency_Strategy<SVC_HANDLER>::dump");
1247 #endif /* ACE_HAS_DUMP */
1250 template <class SVC_HANDLER>
1251 ACE_Reactive_Strategy<SVC_HANDLER>::~ACE_Reactive_Strategy ()
1253 ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::~ACE_Reactive_Strategy");
1257 template <class SVC_HANDLER> void
1258 ACE_Reactive_Strategy<SVC_HANDLER>::dump () const
1260 #if defined (ACE_HAS_DUMP)
1261 ACE_TRACE ("ACE_Reactive_Strategy<SVC_HANDLER>::dump");
1262 #endif /* ACE_HAS_DUMP */
1265 template <class SVC_HANDLER>
1266 ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy ()
1268 ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy");
1271 template <class SVC_HANDLER> void
1272 ACE_Thread_Strategy<SVC_HANDLER>::dump () const
1274 #if defined (ACE_HAS_DUMP)
1275 ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::dump");
1276 #endif /* ACE_HAS_DUMP */
1279 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
1280 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy ()
1282 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Accept_Strategy");
1284 // Close the underlying acceptor.
1285 this->peer_acceptor_.close ();
1288 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_HANDLE
1289 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle () const
1291 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
1292 return this->peer_acceptor_.get_handle ();
1295 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_PEER_ACCEPTOR &
1296 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor () const
1298 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
1299 return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
1302 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> void
1303 ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump () const
1305 #if defined (ACE_HAS_DUMP)
1306 ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
1307 #endif /* ACE_HAS_DUMP */
1310 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
1311 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Connect_Strategy ()
1313 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::~ACE_Connect_Strategy");
1316 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> ACE_PEER_CONNECTOR &
1317 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connector () const
1319 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connector");
1320 return (ACE_PEER_CONNECTOR &) this->connector_;
1323 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> void
1324 ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::dump () const
1326 #if defined (ACE_HAS_DUMP)
1327 ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::dump");
1328 #endif /* ACE_HAS_DUMP */
1331 template <class SVC_HANDLER>
1332 ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy ()
1334 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy");
1337 template <class SVC_HANDLER> void
1338 ACE_Process_Strategy<SVC_HANDLER>::dump () const
1340 #if defined (ACE_HAS_DUMP)
1341 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::dump");
1342 #endif /* ACE_HAS_DUMP */
1345 template <class SVC_HANDLER>
1346 ACE_Scheduling_Strategy<SVC_HANDLER>::~ACE_Scheduling_Strategy ()
1348 ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::~ACE_Scheduling_Strategy");
1351 template <class SVC_HANDLER> int
1352 ACE_Scheduling_Strategy<SVC_HANDLER>::suspend ()
1354 ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::suspend");
1355 return -1;
1358 template <class SVC_HANDLER> int
1359 ACE_Scheduling_Strategy<SVC_HANDLER>::resume ()
1361 ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::resume");
1362 return -1;
1365 template <class SVC_HANDLER> void
1366 ACE_Scheduling_Strategy<SVC_HANDLER>::dump () const
1368 #if defined (ACE_HAS_DUMP)
1369 ACE_TRACE ("ACE_Scheduling_Strategy<SVC_HANDLER>::dump");
1371 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
1372 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
1373 #endif /* ACE_HAS_DUMP */
1376 template <class SVC_HANDLER> int
1377 ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::suspend ()
1379 ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::suspend");
1380 return this->reactor_->suspend_handlers ();
1383 template <class SVC_HANDLER> int
1384 ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::resume ()
1386 ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::resume");
1387 return this->reactor_->resume_handlers ();
1390 template <class SVC_HANDLER> void
1391 ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::dump () const
1393 #if defined (ACE_HAS_DUMP)
1394 ACE_TRACE ("ACE_Schedule_All_Reactive_Strategy<SVC_HANDLER>::dump");
1396 ACE_Scheduling_Strategy<SVC_HANDLER>::dump ();
1397 #endif /* ACE_HAS_DUMP */
1400 template <class SVC_HANDLER> int
1401 ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::suspend ()
1403 ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::suspend");
1404 return this->thr_mgr_->suspend_all ();
1407 template <class SVC_HANDLER> int
1408 ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::resume ()
1410 ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::resume");
1411 return this->thr_mgr_->resume_all ();
1414 template <class SVC_HANDLER> void
1415 ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::dump () const
1417 #if defined (ACE_HAS_DUMP)
1418 ACE_TRACE ("ACE_Schedule_All_Threaded_Strategy<SVC_HANDLER>::dump");
1420 ACE_Scheduling_Strategy<SVC_HANDLER>::dump ();
1421 #endif /* ACE_HAS_DUMP */
1424 template <class T>
1425 ACE_Refcounted_Hash_Recyclable<T>::~ACE_Refcounted_Hash_Recyclable ()
1429 template <class SVC_HANDLER> void
1430 ACE_Singleton_Strategy<SVC_HANDLER>::dump () const
1432 #if defined (ACE_HAS_DUMP)
1433 ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::dump");
1434 #endif /* ACE_HAS_DUMP */
1437 template <class SVC_HANDLER>
1438 ACE_Creation_Strategy<SVC_HANDLER>::~ACE_Creation_Strategy ()
1440 ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::~ACE_Creation_Strategy");
1443 // Default behavior is to make a new SVC_HANDLER, passing in the
1444 // Thread_Manager (if any).
1446 template <class SVC_HANDLER> int
1447 ACE_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
1449 ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::make_svc_handler");
1451 if (sh == 0)
1452 ACE_NEW_RETURN (sh, SVC_HANDLER (this->thr_mgr_), -1);
1453 sh->reactor (this->reactor_);
1454 return 0;
1457 template <class SVC_HANDLER> void
1458 ACE_Creation_Strategy<SVC_HANDLER>::dump () const
1460 #if defined (ACE_HAS_DUMP)
1461 ACE_TRACE ("ACE_Creation_Strategy<SVC_HANDLER>::dump");
1462 #endif /* ACE_HAS_DUMP */
1465 template <class SVC_HANDLER> int
1466 ACE_NOOP_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&)
1468 ACE_TRACE ("ACE_NOOP_Creation_Strategy<SVC_HANDLER>::make_svc_handler");
1469 return 0;
1472 template <class SVC_HANDLER> int
1473 ACE_NOOP_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *,
1474 void *)
1476 ACE_TRACE ("ACE_NOOP_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler");
1477 return 0;
1480 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Creation_Strategy)
1481 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Singleton_Strategy)
1482 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_DLL_Strategy)
1483 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Concurrency_Strategy)
1484 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Reactive_Strategy)
1485 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Thread_Strategy)
1486 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Process_Strategy)
1487 ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Accept_Strategy)
1488 ACE_ALLOC_HOOK_DEFINE_Tco(ACE_Connect_Strategy)
1490 ACE_END_VERSIONED_NAMESPACE_DECL
1492 #endif /* ACE_STRATEGIES_T_CPP */