I'm using libtins to capture packets and moodycamel Concurrent Queue to queue captured packets.
I note that the dequeue operation fails because PDU is an abstract type.
Hence it fails to compile,
error: cannot declare variable ‘pdu’ to be of abstract type ‘Tins::PDU’
I am not sure what to do at this stage to fix this error.
I've attempted the pointer route but it didn't compile too
Tins::PDU *pdu;
if(PacketQueue.try_dequeue(pdu) == false) {
continue;
}
The error,
error: cannot convert ‘std::remove_reference<Tins::PDU&>::type {aka Tins::PDU}’ to ‘Tins::PDU*’ in assignment
element = std::move(el); // NOLINT
~~~~~~~~^~~~~~~~~~~~~~~
Code
moodycamel::ConcurrentQueue<PDU> PacketQueue;
void worker()
{
while(true) {
Tins::PDU pdu;
if(PacketQueue.try_dequeue(pdu) == false) {
continue;
}
// Do Work
}
}
bool callback(PDU &pdu)
{
PacketQueue.enqueue(pdu);
return true;
}