From e686ff78e9ee49e860920d6e41193626edc54bc2 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 24 Jan 2020 14:23:07 +0100 Subject: [PATCH] base: add blockade as derivate of lock Issue #3612 --- repos/base/include/base/blockade.h | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 repos/base/include/base/blockade.h diff --git a/repos/base/include/base/blockade.h b/repos/base/include/base/blockade.h new file mode 100644 index 000000000..03557f459 --- /dev/null +++ b/repos/base/include/base/blockade.h @@ -0,0 +1,36 @@ +/* + * \brief Blockade primitives + * \author Alexander Boettcher + * \date 2020-01-24 + */ + +/* + * Copyright (C) 2020 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _INCLUDE__BASE__BLOCKADE_H_ +#define _INCLUDE__BASE__BLOCKADE_H_ + +#include +#include + +namespace Genode { class Blockade; } + + +class Genode::Blockade : Noncopyable +{ + private: + Lock _lock; + + public: + explicit Blockade() : _lock(Lock::LOCKED) { } + + void block() { _lock.lock(); } + + void wakeup() { _lock.unlock(); } +}; + +#endif /* _INCLUDE__BASE__BLOCKADE_H_ */