void ABuffer::PopPacket() { HEnterSection(lock); while (pktList.size()==0) { HWaitSignal(notEmpty, lock); } pktList.pop_front(); HLeaveSection(lock); HSendSignal(notFull); SendBufferEvents(); }
// Push packet p onto the end of the pktList. Wait for nonFull // if the buffer is full void ABuffer::PutPacket(APacket p) { assert(filter == AnyPacket || p.GetKind() == filter); HEnterSection(lock); while (bsize!=0 && int(pktList.size())>= bsize) { HWaitSignal(notFull, lock); } pktList.push_back(p); HLeaveSection(lock); HSendSignal(notEmpty); SendBufferEvents(); }
// Push packet p onto the end of the pktList. Wait for nonFull // if the buffer is full void ABuffer::PutPacket(APacket p) { assert(filter == AnyPacket || p.GetKind() == filter); for (ABufferListenerList::iterator l = listenerList.begin(); l != listenerList.end(); l++) { ABufferListener *listener = *l; listener->ABufferReceivedPacket(*this, p); } HEnterSection(lock); while (bsize!=0 && int(pktList.size())>= bsize) { HWaitSignal(notFull, lock); } pktList.push_back(p); HLeaveSection(lock); HSendSignal(notEmpty); SendBufferEvents(); }