AsyncStartupWaiter_i Class Reference

#include <AsyncStartupWaiter_i.h>

Collaboration diagram for AsyncStartupWaiter_i:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void wait_for_startup (ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr rh, const char *name)
void unblock_one (const char *name, const char *partial_ior, const char *ior, bool queue)
void unblock_all (const char *name)
void debug (bool dbg)

Private Types

typedef ACE_Vector< PendingDataPendingList
typedef ACE_Strong_Bound_Ptr<
PendingList, ACE_Null_Mutex
PendingListPtr
typedef ACE_Hash_Map_Manager_Ex<
ACE_CString, PendingListPtr,
ACE_Hash< ACE_CString >,
ACE_Equal_To< ACE_CString >,
ACE_Null_Mutex
PendingMap
typedef ACE_Vector< ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var > RHList
typedef ACE_Strong_Bound_Ptr<
RHList, ACE_Null_Mutex
RHListPtr
typedef ACE_Hash_Map_Manager_Ex<
ACE_CString, RHListPtr, ACE_Hash<
ACE_CString >, ACE_Equal_To<
ACE_CString >, ACE_Null_Mutex
WaitingMap

Private Member Functions

ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr get_one_waiter (const char *name)
void get_all_waiters (const char *name, RHList &ret)
void send_response (ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler &rh, const char *name, const char *partial_ior, const char *ior)

Private Attributes

WaitingMap waiting_
PendingMap pending_
bool debug_

Member Typedef Documentation

typedef ACE_Vector<PendingData> AsyncStartupWaiter_i::PendingList [private]
 

Definition at line 31 of file AsyncStartupWaiter_i.h.

Referenced by unblock_one(), and wait_for_startup().

typedef ACE_Strong_Bound_Ptr<PendingList, ACE_Null_Mutex> AsyncStartupWaiter_i::PendingListPtr [private]
 

Definition at line 32 of file AsyncStartupWaiter_i.h.

Referenced by unblock_one(), and wait_for_startup().

typedef ACE_Hash_Map_Manager_Ex<ACE_CString, PendingListPtr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex> AsyncStartupWaiter_i::PendingMap [private]
 

Definition at line 37 of file AsyncStartupWaiter_i.h.

typedef ACE_Vector<ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var> AsyncStartupWaiter_i::RHList [private]
 

Definition at line 39 of file AsyncStartupWaiter_i.h.

Referenced by get_all_waiters(), get_one_waiter(), unblock_all(), and wait_for_startup().

typedef ACE_Strong_Bound_Ptr<RHList, ACE_Null_Mutex> AsyncStartupWaiter_i::RHListPtr [private]
 

Definition at line 40 of file AsyncStartupWaiter_i.h.

Referenced by get_all_waiters(), get_one_waiter(), and wait_for_startup().

typedef ACE_Hash_Map_Manager_Ex<ACE_CString, RHListPtr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex> AsyncStartupWaiter_i::WaitingMap [private]
 

Definition at line 45 of file AsyncStartupWaiter_i.h.


Member Function Documentation

void AsyncStartupWaiter_i::debug bool  dbg  ) 
 

Definition at line 21 of file AsyncStartupWaiter_i.cpp.

Referenced by ImR_Locator_i::init_with_orb().

00022 {
00023   debug_ = dbg;
00024 }

void AsyncStartupWaiter_i::get_all_waiters const char *  name,
RHList ret
[private]
 

Definition at line 151 of file AsyncStartupWaiter_i.cpp.

References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::null(), ACE_Vector< T, DEFAULT_SIZE >::push_back(), RHList, RHListPtr, and waiting_.

Referenced by unblock_all().

00152 {
00153   RHListPtr lst;
00154   waiting_.find (name, lst);
00155   if (! lst.null ()) {
00156     for (size_t i = 0; i < lst->size (); ++i)
00157       {
00158         RHList& tmp = *lst;
00159         ret.push_back (tmp[i]);
00160         // The ACE_Vector will not destruct the elements when cleared, so we must
00161         // make sure to do so here.
00162         tmp[i] = ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler::_nil ();
00163       }
00164     lst->clear ();
00165   }
00166 }

ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr AsyncStartupWaiter_i::get_one_waiter const char *  name  )  [private]
 

Definition at line 135 of file AsyncStartupWaiter_i.cpp.

References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::null(), RHList, RHListPtr, and waiting_.

Referenced by unblock_one().

00136 {
00137   RHListPtr lst;
00138   waiting_.find (name, lst);
00139   if (! lst.null() && lst->size () > 0)
00140     {
00141       RHList& rhlst = *lst;
00142       ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var& tmp = rhlst[rhlst.size () - 1];
00143       ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr ret = tmp._retn ();
00144       rhlst.pop_back ();
00145       return ret;
00146     }
00147   return ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler::_nil ();
00148 }

void AsyncStartupWaiter_i::send_response ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler &  rh,
const char *  name,
const char *  partial_ior,
const char *  ior
[private]
 

Definition at line 59 of file AsyncStartupWaiter_i.cpp.

Referenced by unblock_one(), and wait_for_startup().

00061 {
00062   StartupInfo_var si = new StartupInfo();
00063   si->name = name;
00064   si->partial_ior = partial_ior;
00065   si->ior = ior;
00066 
00067   try
00068     {
00069       rh.wait_for_startup (si.in ());
00070     }
00071   catch (const CORBA::Exception& ex)
00072     {
00073       if (debug_)
00074         ex._tao_print_exception (
00075           "AsyncStartupWaiter_i::send_response ()");
00076     }
00077 }

void AsyncStartupWaiter_i::unblock_all const char *  name  ) 
 

Definition at line 105 of file AsyncStartupWaiter_i.cpp.

References get_all_waiters(), RHList, and ACE_Vector< T, DEFAULT_SIZE >::size().

Referenced by ImR_Locator_i::activate_server_i().

00105                                                    {
00106   RHList tmp;
00107 
00108   get_all_waiters (name, tmp);
00109 
00110   // This startup info should be ignored when unblocking all, because we
00111   // don't know the ior or partial_ior at this point.
00112   StartupInfo_var si = new StartupInfo ();
00113   si->name = name;
00114 
00115   // Note : This method may be called when there are no waiters.
00116 
00117   for (size_t i = 0; i < tmp.size(); ++i)
00118   {
00119     try
00120       {
00121         ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var& rh = tmp[i];
00122 
00123         rh->wait_for_startup (si.in ());
00124       }
00125     catch (const CORBA::Exception& ex)
00126       {
00127         if (debug_)
00128           ex._tao_print_exception (
00129             "AsyncStartupWaiter_i::unblock_all ()");
00130       }
00131   }
00132 }

void AsyncStartupWaiter_i::unblock_one const char *  name,
const char *  partial_ior,
const char *  ior,
bool  queue
 

Definition at line 80 of file AsyncStartupWaiter_i.cpp.

References ACE_ASSERT, ACE_DEBUG, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), get_one_waiter(), CORBA::is_nil(), LM_DEBUG, ACE_Strong_Bound_Ptr< X, ACE_LOCK >::null(), pending_, PendingList, PendingListPtr, and send_response().

Referenced by ImR_Locator_i::server_is_running().

00080                                                                                                          {
00081   ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var rh = get_one_waiter(name);
00082   if (! CORBA::is_nil(rh.in ()))
00083     {
00084       send_response (*rh.in (), name, partial_ior, ior);
00085     }
00086   else if (queue)
00087     {
00088       if (debug_)
00089         ACE_DEBUG((LM_DEBUG, "ImR: Queuing startup info.\n"));
00090 
00091       PendingListPtr lst;
00092       pending_.find (name, lst);
00093       if (lst.null ())
00094         {
00095           lst = PendingListPtr (new PendingList);
00096           int err = pending_.bind (name, lst);
00097           ACE_ASSERT (err == 0);
00098           ACE_UNUSED_ARG (err);
00099         }
00100       lst->push_back (PendingData (partial_ior, ior));
00101     }
00102 }

void AsyncStartupWaiter_i::wait_for_startup ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr  rh,
const char *  name
 

Definition at line 26 of file AsyncStartupWaiter_i.cpp.

References ACE_ASSERT, ACE_DEBUG, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), AsyncStartupWaiter_i::PendingData::ior, LM_DEBUG, ACE_Strong_Bound_Ptr< X, ACE_LOCK >::null(), AsyncStartupWaiter_i::PendingData::partial_ior, pending_, PendingList, PendingListPtr, RHList, RHListPtr, send_response(), and waiting_.

00028 {
00029   PendingListPtr plst;
00030   pending_.find(name, plst);
00031   if (! plst.null () && plst->size () > 0)
00032     {
00033       PendingList& tmp = *plst;
00034       PendingData& pd = tmp[tmp.size () - 1];
00035       tmp.pop_back ();
00036 
00037       if (debug_)
00038         ACE_DEBUG ((LM_DEBUG, "ImR: Skipping wait due to queued startup info for <%s>.\n", name));
00039 
00040       send_response (*rh, name, pd.partial_ior.c_str(), pd.ior.c_str());
00041 
00042     }
00043   else
00044     {
00045       RHListPtr lst;
00046       waiting_.find (name, lst);
00047       if (lst.null ())
00048       {
00049         lst = RHListPtr (new RHList);
00050         int err = waiting_.bind (name, lst);
00051         ACE_ASSERT (err == 0);
00052         ACE_UNUSED_ARG (err);
00053       }
00054       lst->push_back (AMH_AsyncStartupWaiterResponseHandler::_duplicate (rh));
00055     }
00056 }


Member Data Documentation

bool AsyncStartupWaiter_i::debug_ [private]
 

Definition at line 70 of file AsyncStartupWaiter_i.h.

PendingMap AsyncStartupWaiter_i::pending_ [private]
 

Definition at line 69 of file AsyncStartupWaiter_i.h.

Referenced by unblock_one(), and wait_for_startup().

WaitingMap AsyncStartupWaiter_i::waiting_ [private]
 

Definition at line 68 of file AsyncStartupWaiter_i.h.

Referenced by get_all_waiters(), get_one_waiter(), and wait_for_startup().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 15:55:37 2008 for TAO_Implementation_Repository by doxygen 1.3.6