3 #include "ace/OS_NS_sys_time.h"
5 Starter::Starter (CORBA::ORB_ptr orb
)
7 // Initialize the naming service
8 if (this->naming_client_
.init (orb
) != 0)
10 " (%P|%t) Unable to initialize "
11 "the TAO_Naming_Client.\n"));
17 this->resolve_synch_objs ();
25 ACE_Time_Value base_time
= ACE_OS::gettimeofday ();
26 for (Synchs::iterator iterator
= this->synchs_
.begin ();
27 iterator
!= this->synchs_
.end ();
30 (*iterator
).int_id_
.in ()->go (static_cast<CORBA::Long
> (base_time
.sec ()));
35 Starter::resolve_synch_objs (void)
37 CosNaming::Name
name (1);
40 // Get the sender context.
42 CORBA::string_dup ("Synch");
44 CORBA::Object_var object
=
45 this->naming_client_
->resolve (name
);
47 this->synch_context_
=
48 CosNaming::NamingContext::_narrow (object
.in ());
51 CosNaming::BindingIterator_var iterator
;
52 CosNaming::BindingList_var binding_list
;
53 const CORBA::ULong chunk
= 100;
55 // Get the list of synchs registered for this sender.
56 this->synch_context_
->list (chunk
,
60 // Add the receivers found in the bindinglist to the <receivers>.
61 this->add_to_synchs (binding_list
);
63 if (!CORBA::is_nil (iterator
.in ()))
65 CORBA::Boolean more
= 1;
67 // Check to see if there are more receivers listed.
70 more
= iterator
->next_n (chunk
,
73 this->add_to_synchs (binding_list
);
81 Starter::add_to_synchs (CosNaming::BindingList
&binding_list
)
83 ACE_Time_Value base_time
= ACE_OS::gettimeofday ();
84 for (CORBA::ULong i
= 0;
85 i
< binding_list
.length ();
88 // Get the receiver name from the binding list.
89 ACE_CString synch_name
=
90 binding_list
[i
].binding_name
[0].id
.in ();
94 synch_name
.c_str ()));
96 CosNaming::Name
name (1);
99 CORBA::string_dup (synch_name
.c_str ());
101 // Resolve the reference of the receiver from the receiver
103 CORBA::Object_var obj
=
104 this->synch_context_
->resolve (name
);
106 Synch_var synch_obj
=
107 Synch::_narrow (obj
.in ());
110 synch_obj
->go (static_cast<CORBA::Long
> (base_time
.sec ()));
112 // // Add this receiver to the receiver map.
113 // this->synchs_.bind (synch_name,
120 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
124 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
126 Starter
starter (orb
.in ());
131 catch (const CORBA::Exception
& ex
)
133 ex
._tao_print_exception ("Caught exception:");