当前位置: 首页>>代码示例>>C++>>正文


C++ ACE_Message_Block::release方法代码示例

本文整理汇总了C++中ACE_Message_Block::release方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Message_Block::release方法的具体用法?C++ ACE_Message_Block::release怎么用?C++ ACE_Message_Block::release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ACE_Message_Block的用法示例。


在下文中一共展示了ACE_Message_Block::release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Exception

  ////////////////////////////////////////////////////////////////////////
  // Now the svc() method where everything interesting happens.
  //
  int 
  LaserTask::svc()
  {
    MIRO_DBG_OSTR(SICK, LL_DEBUG, "("<<(void *) this <<"|"<<ACE_Thread::self ()<<") Task 0x%x starts in thread %u\n");

    // Where we getq() the message
    ACE_Message_Block *message;
    LaserMessage * data;

    while (true) {
      // Get the message...
      if (getq (message) == -1) {
	throw Miro::Exception("LaserTask::svc: could not getq from message queue");
      }

      // Is it a shutdown request?
      if (message->msg_type () == ACE_Message_Block::MB_HANGUP) {
	break;
      }

      // Get the LaserMessage pointer out of the ACE message block.
      data = (LaserMessage*)message->rd_ptr ();
      if (!data) 
	throw Miro::Exception("LaserTask::svc: got empty message block");
      
      doPkt( data );

      // throw away message block
      message->release ();
    }

    MIRO_LOG(LL_NOTICE, "left service.");

    return (0);
  }
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:38,代码来源:SickLaserTask.cpp

示例2: while

int
Terminator::svc()
{
  while (1)
    {
      ACE_Message_Block* mb = 0;
      if (this->getq(mb) == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%P|%t|%T) ERROR: Terminator::svc() could not get "
                             "message block from queue"), -1);
        }

      if (mb->msg_type () == ACE_Message_Block::MB_HANGUP)
        {
          mb->release ();
          break;
        }
      int delay_secs = ACE_OS::atoi(mb->rd_ptr());
      ACE_DEBUG ((LM_DEBUG,
                  "(%P|%t|%T) Terminator::svc() Sleeping %d seconds before aborting\n", delay_secs));
      ACE_OS::sleep(delay_secs);
      ACE_OS::abort();
    }
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:26,代码来源:Terminator.cpp

示例3:

static void *
consumer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue)
{
  // Keep looping, reading a message out of the queue, until we
  // timeout or get a message with a length == 0, which signals us to
  // quit.

  for (;;)
    {
      ACE_Message_Block *mb = 0;

      if (msg_queue->dequeue_head (mb) == -1)
        break;

      int length = ACE_Utils::truncate_cast<int> (mb->length ());

      if (length > 0)
        ACE_OS::puts (mb->rd_ptr ());

      // Free up the buffer memory and the Message_Block.
      ACE_Allocator::instance ()->free (mb->rd_ptr ());
      mb->release ();

      if (length == 0)
        break;
    }

  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:29,代码来源:priority_buffer.cpp

示例4: svc

  virtual int svc (void)
  {
    ACE_Thread_ID id;
    thread_id_ = id;
    while (1)
      {
        ACE_Message_Block *mb = 0;
        if (this->getq (mb) == -1)
          ACE_ERROR_BREAK
            ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("getq")));
        if (mb->msg_type () == ACE_Message_Block::MB_HANGUP)
          {
            ACE_DEBUG ((LM_INFO,
                        ACE_TEXT ("(%t) Shutting down\n")));
            mb->release ();
            break;
          }
        // Process the message.
        process_message (mb);
        // Return to work.
        this->manager_->return_to_work (this);
      }

    return 0;
  }
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:25,代码来源:ThreadPool.cpp

示例5:

void
JAWS_Asynch_IO::send_message (JAWS_IO_Handler *ioh,
                              const char *buffer,
                              unsigned int length,
                              long act)
{
  ioh->idle ();

  JAWS_Asynch_IO_Handler *aioh =
    dynamic_cast<JAWS_Asynch_IO_Handler *> (ioh);

  ACE_Message_Block *mb = 0;
  ACE_NEW (mb, ACE_Message_Block (buffer, length));

  if (mb == 0)
    {
      this->handler_->error_message_complete ();
      return;
    }

  ACE_Asynch_Write_Stream aw;
  if (aw.open (*(aioh->handler ()), aioh->handle ()) == -1
      || aw.write (*mb, length, (void *) static_cast<intptr_t> (act)) == -1)
    {
      mb->release ();

      if (act == CONFIRMATION)
        ioh->confirmation_message_complete ();
      else
        ioh->error_message_complete ();
    }
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:32,代码来源:Jaws_IO.cpp

示例6: release_cfentries

void release_cfentries(ACE_Message_Block& mb_hdr)
{
  ACE_Message_Block* cf = mb_hdr.cont();
  mb_hdr.cont(mb_hdr.cont()->cont());
  cf->cont(0);
  cf->release();
}
开发者ID:tornadoxutao,项目名称:OpenDDS,代码行数:7,代码来源:Fragmentation.cpp

示例7: svc

int SiteWorkTask::svc()
{
	ImageCommRequestArgs *pImageCommRequestArgs = NULL;

	SetupDefaultComments();

	while(true)
	{
		try
		{
			ACE_Message_Block *mb = NULL;
			if( getq(mb) == -1 )
			{
				break;
			}

			if( mb->msg_type() == ACE_Message_Block::MB_STOP )
			{
				mb->release();
				break;
			}

			if (NULL == mb)
			{
				continue;
			}

			memcpy(&pImageCommRequestArgs, mb->rd_ptr(), sizeof(pImageCommRequestArgs));
			onCommandRequest(pImageCommRequestArgs);

			delete pImageCommRequestArgs;
			mb->release();

			if (_pSiteRenderTask)
			{
				_pSiteRenderTask->Process();
			}
		}
		catch(...)
		{
			//throw "work task crashed";
			LOG_ERROR("catch exception.");
		}
	}

	return 0;
}
开发者ID:herofyf,项目名称:McsfDj2DEngine,代码行数:47,代码来源:site_work_task.cpp

示例8:

template <class BARRIER> int
Worker_Task<BARRIER>::svc (void)
{
  // Note that the <ACE_Task::svc_run> method automatically adds us to
  // the Thread_Manager when the thread begins.

  // Keep looping, reading a message out of the queue, until we get a
  // message with a length == 0, which signals us to quit.

  for (int iter = 1; ;iter++)
    {
      ACE_Message_Block *mb = 0;

      int result = this->getq (mb);

      if (result == -1)
        {
          ACE_ERROR ((LM_ERROR,
                      "(%t) in iteration %d\n",
                      "error waiting for message in iteration",
                      iter));
          break;
        }

      size_t length = mb->length ();
      this->service (mb,iter);

      if (length == 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "(%t) in iteration %d got quit, exit!\n",
                      iter));
                      mb->release ();
          break;
        }

      this->barrier_.wait ();
      this->output (mb);

      mb->release ();
    }

  // Note that the <ACE_Task::svc_run> method automatically removes us
  // from the Thread_Manager when the thread exits.

  return 0;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:47,代码来源:barrier2.cpp

示例9: sizeof

static void *
connector (void *)
{
  ACE_UPIPE_Stream c_stream;

  ACE_OS::sleep (5);

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) connector starting connect\n")));
  ACE_UPIPE_Connector con;

  if (con.connect (c_stream, addr) == -1)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) connector ACE_UPIPE_Connector failed\n")));

  ACE_Message_Block *mb = 0;

  ACE_NEW_RETURN (mb, ACE_Message_Block (sizeof ("hello thanks") * sizeof (char)), 0);

  mb->copy ("hello");

  if (c_stream.send (mb) == -1)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) error connector send\n")));

  if (c_stream.recv (mb) == -1)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) error connector recv\n")));

  ACE_TEST_ASSERT (ACE_OS::strcmp (mb->rd_ptr (), "thanks") == 0);

  // Free up the memory block.
  mb->release ();

  // Now try the send()/recv() interface.
  char mytext[] = "This string is sent by connector as a buffer";

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) connector sending text\n")));
  if (c_stream.send (mytext, sizeof (mytext)) == -1)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%t) buffer send from connector failed\n")));

  char conbuf[BUFSIZ];  // Buffer to receive response.

  int i = 0;

  for (char c = ' '; c != '!'; i++)
    {
      if (c_stream.recv (&c, 1) == -1)
        ACE_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("(%t) buffer recv from connector failed\n")));
      else
        conbuf[i] = c;
    }

  conbuf[i] = '\0';
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) conbuf = %s\n"), conbuf));
  ACE_TEST_ASSERT (ACE_OS::strcmp (conbuf, "this is the acceptor response!") == 0);

  c_stream.close ();
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) exiting thread\n")));
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:59,代码来源:UPIPE_SAP_Test.cpp

示例10: switch

int
Peer_Handler::handle_output (ACE_HANDLE)
{
  ACE_Message_Block *mb = 0;

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("in handle_output\n")));

  if (this->msg_queue ()->dequeue_head
      (mb,
       (ACE_Time_Value *) &ACE_Time_Value::zero) != -1)
    {
      switch (this->nonblk_put (mb))
        {
        case 0:           // Partial send.
          ACE_ASSERT (errno == EWOULDBLOCK);
          // Didn't write everything this time, come back later...
          break;
          /* NOTREACHED */
        case -1:
          // Caller is responsible for freeing a ACE_Message_Block if
          // failures occur.
          mb->release ();
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("%p\n"),
                      ACE_TEXT ("transmission failure in handle_output")));
          /* FALLTHROUGH */
        default: // Sent the whole thing.
          // If we succeed in writing the entire event (or we did not
          // fail due to EWOULDBLOCK) then check if there are more
          // events on the <ACE_Message_Queue>.  If there aren't, tell
          // the <ACE_Reactor> not to notify us anymore (at least
          // until there are new events queued up).

          if (this->msg_queue ()->is_empty ())
            {
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("queue now empty on handle %d to connection id %d\n"),
                          this->get_handle (),
                          this->connection_id_));

              if (ACE_Reactor::instance ()->cancel_wakeup
                  (this, ACE_Event_Handler::WRITE_MASK) == -1)
                ACE_ERROR ((LM_ERROR,
                            ACE_TEXT ("%p\n"),
                            ACE_TEXT ("cancel_wakeup")));
            }
        }
      return 0;
    }
  else
    // If the list is empty there's a bug!
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("dequeue_head")),
                      0);
}
开发者ID:manut,项目名称:ACE,代码行数:57,代码来源:Peer.cpp

示例11: handle_input

// Called when input is available from the client
//
// We can handle requests until the peer closes on, potentially, many connections simultaneously.
// We do this asynchronously, acoiding blocking I/O operations which are bad because they block all connection processing. 
//
int ClientService::handle_input(ACE_HANDLE fileDescriptor)
{
	const size_t inputSize = 4096;
	char		 buffer[inputSize];
	ssize_t		 receivedBytes;
	ssize_t		 sentBytes;

	if ((receivedBytes = m_socket.recv(buffer, sizeof(buffer))) <= 0)
	{
		ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Connection closed\n")));
		return -1;
	}

	sentBytes = m_socket.send(buffer, static_cast<size_t>(receivedBytes));

	if (sentBytes == receivedBytes)
	{
		return 0;
	}

	if (sentBytes == -1 && ACE_OS::last_error() != EWOULDBLOCK)
	{
		ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) %p\n"), ACE_TEXT("send")), 0);
	}

	if (sentBytes == -1)
	{
		sentBytes = 0;
	}

	//
	ACE_Message_Block* message;

	size_t remaining = static_cast<size_t>(receivedBytes - sentBytes);

	ACE_NEW_RETURN(message, ACE_Message_Block(remaining), -1);

	message->copy(&buffer[sentBytes], remaining);

	bool isEmpty = m_queue.is_empty();

	ACE_Time_Value nowait(ACE_OS::gettimeofday());

	if (m_queue.enqueue_tail(message, &nowait) == -1)
	{
		ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) %p; discarding data\n"), ACE_TEXT("enqueue failed")));
		message->release();
		return 0;
	}

	if (isEmpty)
	{
		return this->reactor()->register_handler(this, ACE_Event_Handler::WRITE_MASK);		
	}

	return 0;
}
开发者ID:xy365,项目名称:ACE-Samples,代码行数:62,代码来源:ClientService.cpp

示例12:

int
Thread_Pool::svc (void)
{
  // Keep looping, reading a message out of the queue, until we get a
  // message with a length == 0, which signals us to quit.

  for (int count = 1; ; count++)
    {
      ACE_Message_Block *mb = 0;

      int result = this->getq (mb);

      ACE_TEST_ASSERT (result != -1 || errno == ESHUTDOWN);

      if (result == -1 && errno == ESHUTDOWN)
        {
          // The queue has been deactivated, so let's bail out.
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%t) in iteration %d, queue len = %d, ")
                      ACE_TEXT ("queue deactivated, exiting\n"),
                      count,
                      this->msg_queue ()->message_count ()));

          break;
        }

      size_t length = mb->length ();

      if (length > 0)
        ACE_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("(%t) in iteration %d, queue len = %d, ")
                    ACE_TEXT ("length = %d, text = \"%*s\"\n"),
                    count,
                    this->msg_queue ()->message_count (),
                    length,
                    length - 1,
                    mb->rd_ptr ()));

      // We're responsible for deallocating this.
      mb->release ();

      if (length == 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%t) in iteration %d, queue len = %d, ")
                      ACE_TEXT ("got \"empty\" message, exiting\n"),
                      count,
                      this->msg_queue ()->message_count ()));
          break;
        }
    }

  // Note that the <ACE_Task::svc_run> method automatically removes us
  // from the <ACE_Thread_Manager> when the thread exits.
  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:56,代码来源:Thread_Pool_Test.cpp

示例13: clear

void SerialportTask::clear()
{
    while (!message_queue.is_empty())
    {
        ACE_Message_Block *b = 0;
        message_queue.dequeue(b);

        b->release();
    }
}
开发者ID:hisilicon,项目名称:IoTGateway,代码行数:10,代码来源:Zigbee_Serialport_Service.cpp

示例14: handle_output

int RealmSocket::handle_output(ACE_HANDLE)
{
    if (closing_)
        return -1;

    ACE_Message_Block* mb = 0;

    if (msg_queue()->is_empty())
    {
        reactor()->cancel_wakeup(this, ACE_Event_Handler::WRITE_MASK);
        return 0;
    }

    if (msg_queue()->dequeue_head(mb, (ACE_Time_Value *)(&ACE_Time_Value::zero)) == -1)
        return -1;

    ssize_t n = noblk_send(*mb);

    if (n < 0)
    {
        mb->release();
        return -1;
    }
    else if (size_t(n) == mb->length())
    {
        mb->release();
        return 1;
    }
    else
    {
        mb->rd_ptr(n);

        if (msg_queue()->enqueue_head(mb, (ACE_Time_Value *) &ACE_Time_Value::zero) == -1)
        {
            mb->release();
            return -1;
        }

        return 0;
    }

    ACE_NOTREACHED(return -1);
}
开发者ID:Caydan,项目名称:DeathCore,代码行数:43,代码来源:RealmSocket.cpp

示例15: svc

  virtual int svc (void)
  {
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) starting up %C\n"),
                name_));

    ACE_OS::sleep (2);
    ACE_Message_Block *mb = 0;
    while (this->getq (mb) != -1)
      {
        if (mb->msg_type () == ACE_Message_Block::MB_BREAK)
          {
            mb->release ();
            break;
          }
        process_message (mb);
        mb->release ();
      }
    return 0;
  }
开发者ID:asdlei00,项目名称:ACE,代码行数:19,代码来源:Priorities.cpp


注:本文中的ACE_Message_Block::release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。