Example #1
0
/* copies elements from original q to new q and then swaps the contents of the
 * two q headers. This is so that if anyone is holding a pointer to q it will
 * still work
 */
static int resize_finish(struct rxe_queue *q, struct rxe_queue *new_q,
			 unsigned int num_elem)
{
	if (!queue_empty(q) && (num_elem < queue_count(q)))
		return -EINVAL;

	while (!queue_empty(q)) {
		memcpy(producer_addr(new_q), consumer_addr(q),
		       new_q->elem_size);
		advance_producer(new_q);
		advance_consumer(q);
	}

	swap(*q, *new_q);

	return 0;
}
Example #2
0
int
Event_Channel::initiate_acceptors (void)
{
  if (Options::instance ()->enabled (Options::CONSUMER_ACCEPTOR))
    {
      ACE_INET_Addr
        consumer_addr (Options::instance ()->consumer_acceptor_port ());
      if (this->consumer_acceptor_.open
          (consumer_addr,
           ACE_Reactor::instance (),
           Options::instance ()->blocking_semantics ()) == -1)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "%p\n",
                           "cannot register acceptor"),
                          -1);
      else
        ACE_DEBUG ((LM_DEBUG,
                    "accepting Consumers at %d\n",
                    Options::instance ()->consumer_acceptor_port ()));
    }
  if (Options::instance ()->enabled (Options::SUPPLIER_ACCEPTOR))
    {
      ACE_INET_Addr
        supplier_addr (Options::instance ()->supplier_acceptor_port ());
      if (this->supplier_acceptor_.open
          (supplier_addr,
           ACE_Reactor::instance (),
           Options::instance ()->blocking_semantics ()) == -1)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "%p\n",
                           "cannot register acceptor"),
                          -1);
      else
        ACE_DEBUG ((LM_DEBUG,
                    "accepting Suppliers at %d\n",
                    Options::instance ()->supplier_acceptor_port ()));
    }

  return 0;
}