本文整理汇总了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();
}
}
};
示例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;
};