00001
00002 #include "tao/Thread_Per_Connection_Handler.h"
00003 #include "tao/Connection_Handler.h"
00004 #include "tao/debug.h"
00005 #include "tao/Transport.h"
00006 #include "tao/ORB_Core.h"
00007 #include "ace/Flag_Manip.h"
00008
00009 ACE_RCSID (tao,
00010 Thread_Per_Connection_Handler,
00011 "$Id: Thread_Per_Connection_Handler.cpp 71473 2006-03-10 07:19:20Z jtc $")
00012
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015 TAO_Thread_Per_Connection_Handler::TAO_Thread_Per_Connection_Handler (
00016 TAO_Connection_Handler *ch,
00017 TAO_ORB_Core *oc)
00018 : TAO_TPC_BASE (oc->thr_mgr ())
00019 , ch_ (ch)
00020 {
00021 this->ch_->transport ()->add_reference ();
00022 }
00023
00024 TAO_Thread_Per_Connection_Handler::~TAO_Thread_Per_Connection_Handler (void)
00025 {
00026 this->ch_->close_connection ();
00027 this->ch_->transport ()->remove_reference ();
00028 }
00029
00030 int
00031 TAO_Thread_Per_Connection_Handler::activate (long flags,
00032 int n_threads,
00033 int force_active,
00034 long priority,
00035 int grp_id,
00036 ACE_Task_Base *task,
00037 ACE_hthread_t thread_handles[],
00038 void *stack[],
00039 size_t stack_size[],
00040 ACE_thread_t thread_names[])
00041 {
00042 if (TAO_debug_level)
00043 {
00044 ACE_DEBUG ((LM_DEBUG,
00045 ACE_TEXT ("TAO (%P|%t) - Thread_Per_Connection_Handler::")
00046 ACE_TEXT ("activate %d threads, flags = %d\n"),
00047 n_threads,
00048 flags));
00049 }
00050
00051 return TAO_TPC_BASE::activate (flags,
00052 n_threads,
00053 force_active,
00054 priority,
00055 grp_id,
00056 task,
00057 thread_handles,
00058 stack,
00059 stack_size,
00060 thread_names);
00061 }
00062
00063 int
00064 TAO_Thread_Per_Connection_Handler::svc (void)
00065 {
00066 ACE::clr_flags (this->ch_->transport ()->event_handler_i ()->get_handle (),
00067 ACE_NONBLOCK);
00068
00069
00070 return this->ch_->svc_i ();
00071 }
00072
00073 int
00074 TAO_Thread_Per_Connection_Handler::open (void*v)
00075 {
00076 return this->ch_->open_handler (v);
00077 }
00078
00079 int
00080 TAO_Thread_Per_Connection_Handler::close (u_long)
00081 {
00082 delete this;
00083
00084 return 0;
00085 }
00086
00087 TAO_END_VERSIONED_NAMESPACE_DECL