本文整理汇总了C++中ACE_Message_Block::self_flags方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Message_Block::self_flags方法的具体用法?C++ ACE_Message_Block::self_flags怎么用?C++ ACE_Message_Block::self_flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Message_Block
的用法示例。
在下文中一共展示了ACE_Message_Block::self_flags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
Worker_Task::svc (void)
{
// Start synchronization
(void) this->synch_.start_synchronization ();
for (;;)
{
ACE_Message_Block *mb = 0;
int result = this->getq (mb);
if (result == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Worker_Task::svc (%t) -> %p\n",
"getq error"),
-1);
}
// Get the flag in the message blok
ACE_Message_Block::Message_Flags flag =
mb->self_flags ();
// The stop flag
int stop_flag = 0;
// Check for the stop flag
if (ACE_BIT_ENABLED (flag,
Synchronisers::MB_STOP_FLAG))
{
if (debug)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) saw flag after [%d] messages\n",
this->messages_processed_));
}
stop_flag = 1;
}
// Release the message block
mb->release ();
// Counter.
++this->messages_processed_;
if (debug)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) dequeued my %d message\n",
this->messages_processed_));
}
//
// Process message here.
//
for (size_t j = 0; j < message_size; ++j)
{
// Eat a little CPU
/* takes about 40.2 usecs on a 167 MHz Ultra2 */
u_long n = 11UL;
ACE::is_prime (n, 2, n / 2);
}
// Make a message block for writing onto output queue
ACE_Message_Block *message_block = 0;
ACE_NEW_RETURN (message_block,
ACE_Message_Block (data_block),
-1);
// Put this message block into the next queue or the output
// queue
result = this->put_next (message_block);
if (result == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Input::svc (%t) -> %p\n",
"putq error"),
-1);
}
// If the stop_flag is set just break and wait..
if (stop_flag)
{
if (debug)
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Got stop message after [%d] messages \n",
this->messages_processed_));
break;
}
}
(void) this->synch_.end_synchronization ();
return 0;
}