2 #include "tao/Messaging/Messaging.h"
3 #include "tao/AnyTypeCode/Any.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/OS_NS_sys_time.h"
7 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:i:"));
16 while ((c
= get_opts ()) != -1)
20 ior
= get_opts
.opt_arg ();
24 iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
29 ACE_ERROR_RETURN ((LM_ERROR
,
37 // Indicates successful parsing of the command line
42 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
47 CORBA::ORB_init (argc
, argv
);
49 if (parse_args (argc
, argv
) != 0)
52 CORBA::Object_var tmp
=
53 orb
->string_to_object(ior
);
55 Test::Blocking_Sync_None_var blocking_sync_none
=
56 Test::Blocking_Sync_None::_narrow(tmp
.in ());
58 if (CORBA::is_nil (blocking_sync_none
.in ()))
59 ACE_ERROR_RETURN ((LM_DEBUG
,
60 "ERROR: Nil reference in Blocking_Sync_None reference <%s>\n",
64 CORBA::Object_var object
=
65 orb
->resolve_initial_references ("PolicyCurrent");
67 CORBA::PolicyCurrent_var policy_current
=
68 CORBA::PolicyCurrent::_narrow (object
.in ());
70 if (CORBA::is_nil (policy_current
.in ()))
72 ACE_ERROR ((LM_ERROR
, "ERROR: Nil policy current\n"));
75 CORBA::Any scope_as_any
;
76 scope_as_any
<<= Messaging::SYNC_NONE
;
78 CORBA::PolicyList
policies(1); policies
.length (1);
80 orb
->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE
,
83 policy_current
->set_policy_overrides (policies
, CORBA::ADD_OVERRIDE
);
85 policies
[0]->destroy ();
87 const int payload_length
= 65536;
88 const unsigned int sleep_milliseconds
= 20;
89 const unsigned int sleep_microseconds
= sleep_milliseconds
* 1000;
91 Test::Payload
payload(payload_length
);
92 payload
.length (payload_length
);
94 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) Test running . . .\n"));
95 int blocked_calls
= 0;
96 for (int i
= 0; i
!= iterations
; ++i
)
98 ACE_Time_Value start
= ACE_OS::gettimeofday ();
100 blocking_sync_none
->slow_operation (payload
,
103 ACE_Time_Value elapsed
= ACE_OS::gettimeofday ();
106 if (elapsed
.msec () >= sleep_milliseconds
)
112 blocking_sync_none
->shutdown ();
116 if (blocked_calls
> iterations
/ 20)
118 ACE_ERROR ((LM_ERROR
,
119 "ERROR: More than 5% (%d) of the calls blocked\n",
124 if (blocked_calls
!= 0)
126 ACE_ERROR ((LM_ERROR
,
127 "Warning: Some (%d) SYNC_NONE calls blocked\n",
131 catch (const CORBA::Exception
& ex
)
133 ex
._tao_print_exception ("Exception caught:");