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


C++ Filter::getQueue方法代码示例

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


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

示例1: while

void *Filter::filterProcess(void *arg)
{
  Filter *filter = Filter::instance;
  Packet *p;
  bool keepPacket;
  vector<PacketProcessor *>::iterator it;

  while (!filter->exitFlag)
  {
    // get a packet...
    p = filter->getQueue()->pop();
    filter->pktIn++;
    
    // run packet through all packetProcessors
    for (it = filter->processors.begin(); it != filter->processors.end(); ++it)
    {
      keepPacket = (*it)->processPacket(p);
      if (!keepPacket)
        break;
    }
    
    //check if we passed all filters
    if (keepPacket)
    {
      // get the packet to the receiver
      filter->receiver->push(p);
      filter->pktOut++;
    }
    else
    {
      // immediately drop the packet
      p->release();
    }
  }
};
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:35,代码来源:Filter.cpp

示例2: line

/*
 this is the main filter process, running within a thread
 each packet is run thru a series of PacketProcessors and then pushed
 to the next system in line (represented thru a ConcurrentQueue)
 */
void *Filter::filterProcess(void *arg)
{
	Packet *p;
	vector<PacketProcessor *>::iterator it;

	// get back the object from the arg
	Filter *filter = (Filter *)arg;

	/*
	 set to true so packet is always pushed to receiver
	 even if the pp-iterator below is NULL
	 */
	bool keepPacket=true;


	/* for dumb compilers, do CSE here to spare some cycles below */
	ConcurrentQueue<Packet*> *in_q=filter->getQueue();
	ConcurrentQueue<Packet*> *out_q=filter->receiver;

	msg(MSG_INFO, "now running the filter thread");
	while(!filter->exitFlag) {

		//DPRINTF("Count is %d\n", in_q->getCount());

		// get a packet
		DPRINTFL(MSG_VDEBUG, "trying to get packet");
		if (!in_q->pop(&p)) break;

		DPRINTFL(MSG_VDEBUG, "got packet");
		filter->processedPackets++;

		// run packet through all packetProcessors
		for(it = filter->processors.begin(); it != filter->processors.end(); ++it) {
			keepPacket = (*it)->processPacket(p);

			if(!keepPacket) {
				break;
			}
		}

		// check if we passed all filters
		if(keepPacket) {
			// push packet to the receiver
			DPRINTF("pushing packet %d", p);
			out_q->push(p);
		} else {
			// immediately drop the packet
			DPRINTF("releasing packet");
			p->removeReference();
		}
	}
	return 0;
};
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:58,代码来源:Filter.cpp


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