From 6f377ec4c5fe6ae2d0696839aeb87d273a8eed52 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 1 Dec 2014 15:09:51 +0100 Subject: [PATCH] hw: add FIFO variant with for_each() method ref #1102 --- repos/base-hw/src/core/include/kernel/fifo.h | 43 +++++++++++++++++++ .../src/core/include/kernel/ipc_node.h | 6 +-- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 repos/base-hw/src/core/include/kernel/fifo.h diff --git a/repos/base-hw/src/core/include/kernel/fifo.h b/repos/base-hw/src/core/include/kernel/fifo.h new file mode 100644 index 0000000000..c2135acf8e --- /dev/null +++ b/repos/base-hw/src/core/include/kernel/fifo.h @@ -0,0 +1,43 @@ +/* + * \brief Queue with first-in first-out semantics + * \author Martin Stein + * \date 2012-11-30 + */ + +/* + * Copyright (C) 2014 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _KERNEL__FIFO_H_ +#define _KERNEL__FIFO_H_ + +/* Genode includes */ +#include + +namespace Kernel { + + /** + * Queue with first-in first-out semantics + * + * \param T queue element type + */ + template + class Fifo : public Genode::Fifo + { + public: + + /** + * Call function 'f' of type 'void (QT *)' for each queue element + */ + template void for_each(F f) + { + typedef Genode::Fifo B; + for (T * e = B::head(); e; e = e->B::Element::next()) { f(e); } + } + }; +} + +#endif /* _KERNEL__FIFO_H_ */ diff --git a/repos/base-hw/src/core/include/kernel/ipc_node.h b/repos/base-hw/src/core/include/kernel/ipc_node.h index 2d1bcbd86f..9ef97ddcf8 100644 --- a/repos/base-hw/src/core/include/kernel/ipc_node.h +++ b/repos/base-hw/src/core/include/kernel/ipc_node.h @@ -14,10 +14,8 @@ #ifndef _KERNEL__IPC_NODE_H_ #define _KERNEL__IPC_NODE_H_ -/* Genode includes */ -#include - /* core includes */ +#include #include namespace Kernel @@ -45,7 +43,7 @@ class Kernel::Ipc_node class Message_buf; - typedef Genode::Fifo Message_fifo; + typedef Kernel::Fifo Message_fifo; /** * Describes the buffer for incoming or outgoing messages