From 6a186f6ed0045b1ec6a18a2ecec1c441caf26b8a Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Mon, 30 Nov 2015 14:16:24 +0100 Subject: [PATCH] packet_stream: implement peek_packet function issue #1800 --- repos/os/include/os/packet_stream.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/repos/os/include/os/packet_stream.h b/repos/os/include/os/packet_stream.h index e6c252ea0..53d56bc6c 100644 --- a/repos/os/include/os/packet_stream.h +++ b/repos/os/include/os/packet_stream.h @@ -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 *