packet_stream: implement peek_packet function

issue #1800
This commit is contained in:
Sebastian Sumpf 2015-11-30 14:16:24 +01:00 committed by Christian Helmuth
parent f58cc1e83c
commit 6a186f6ed0
1 changed files with 24 additions and 0 deletions

View File

@ -212,6 +212,14 @@ class Genode::Packet_descriptor_queue
return packet;
}
/**
* Return current packet descriptor
*/
PACKET_DESCRIPTOR peek()
{
return _queue[_tail%QUEUE_SIZE];
}
/**
* Return true if packet-descriptor queue is empty
*/
@ -404,6 +412,12 @@ class Genode::Packet_descriptor_receiver
if (_rx_queue->single_slot_free())
_tx_ready.submit();
}
typename RX_QUEUE::Packet_descriptor_queue rx_peek()
{
Genode::Lock::Guard lock_guard(_rx_queue_lock);
return _rx_queue->peek();
}
};
@ -798,6 +812,16 @@ class Genode::Packet_stream_sink : private Packet_stream_base
return packet;
}
/**
* Return but do not dequeue next packet
*
* If there is no packet, an invalid packet descriptor is returned.
*/
Packet_descriptor peek_packet()
{
return _submit_receiver.rx_peek();
}
/**
* Get pointer to the content of the specified packet
*