本文整理汇总了C++中Sender::send_message方法的典型用法代码示例。如果您正苦于以下问题:C++ Sender::send_message方法的具体用法?C++ Sender::send_message怎么用?C++ Sender::send_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sender
的用法示例。
在下文中一共展示了Sender::send_message方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: safe_sender
int
Invocation_Thread::svc (void)
{
int connection_counter = 0;
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT("(%t) Invocation_Thread::svc commencing\n")));
disable_signal (SIGPIPE, SIGPIPE);
for (int message_counter = 1;; ++message_counter)
{
// Get a connection from the cache.
Sender *sender =
this->connection_cache_.acquire_connection ();
// If no connection is available in the cache, create a new one.
if (sender == 0)
{
if (connection_counter < number_of_connections)
{
sender = this->create_connection ();
// This lets the Close_Socket_Thread know that the new
// connection has been created.
int result =
this->new_connection_event_.signal ();
ACE_TEST_ASSERT (result == 0);
ACE_UNUSED_ARG (result);
++connection_counter;
message_counter = 1;
}
else
// Stop the thread, if the maximum number of connections
// for the test has been reached.
break;
}
// The reference count on the sender was increased by the cache
// before it was returned to us.
ACE_Event_Handler_var safe_sender (sender);
// If the test does not require making invocations, immediately
// release the connection.
if (!this->make_invocations_)
{
this->connection_cache_.release_connection (sender);
// Sleep for a short while
ACE_OS::sleep (ACE_Time_Value (0, 10 * 1000));
}
else
{
// Make invocation.
ssize_t result =
sender->send_message ();
// If successful, release connection.
if (result == message_size)
{
if (debug)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%t) Message %d:%d delivered on handle %d\n"),
connection_counter,
message_counter,
sender->handle_));
this->connection_cache_.release_connection (sender);
}
else
{
// If failure in making invocation, close the sender.
if (debug)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%t) /*** Problem in delivering message ")
ACE_TEXT ("%d:%d on handle %d: shutting down ")
ACE_TEXT ("invocation thread ***/\n"),
connection_counter,
message_counter,
sender->handle_));
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%t) Invocation thread calling ")
ACE_TEXT ("Sender::close() for handle %d\n"),
sender->handle_));
sender->close ();
}
}
}
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT("(%t) Invocation_Thread::svc calling end_reactor_event_loop\n")));
// Close the Reactor event loop.
this->reactor_.end_reactor_event_loop ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT("(%t) Invocation_Thread::svc terminating\n")));
return 0;
}