hw: add FIFO variant with for_each() method

ref #1102
This commit is contained in:
Martin Stein 2014-12-01 15:09:51 +01:00 committed by Christian Helmuth
parent 9c027fd9bd
commit 6f377ec4c5
2 changed files with 45 additions and 4 deletions

View File

@ -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 <util/fifo.h>
namespace Kernel {
/**
* Queue with first-in first-out semantics
*
* \param T queue element type
*/
template <typename T>
class Fifo : public Genode::Fifo<T>
{
public:
/**
* Call function 'f' of type 'void (QT *)' for each queue element
*/
template <typename F> void for_each(F f)
{
typedef Genode::Fifo<T> B;
for (T * e = B::head(); e; e = e->B::Element::next()) { f(e); }
}
};
}
#endif /* _KERNEL__FIFO_H_ */

View File

@ -14,10 +14,8 @@
#ifndef _KERNEL__IPC_NODE_H_
#define _KERNEL__IPC_NODE_H_
/* Genode includes */
#include <util/fifo.h>
/* core includes */
#include <kernel/fifo.h>
#include <assert.h>
namespace Kernel
@ -45,7 +43,7 @@ class Kernel::Ipc_node
class Message_buf;
typedef Genode::Fifo<Message_buf> Message_fifo;
typedef Kernel::Fifo<Message_buf> Message_fifo;
/**
* Describes the buffer for incoming or outgoing messages