/* * \brief Io receptor registry * \author Josef Soentgen * \date 2012-10-05 */ /* * Copyright (C) 2012-2013 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 _NOUX__IO_RECEPTOR_REGISTRY_H_ #define _NOUX__IO_RECEPTOR_REGISTRY_H_ /* Genode includes */ #include #include #include namespace Noux { struct Io_receptor : List::Element { private: Semaphore *_sem; public: Io_receptor(Semaphore *semaphore) : _sem(semaphore) { } void check_and_wakeup() { if (_sem) _sem->up(); } }; class Io_receptor_registry { private: List _receptors; Lock _receptors_lock; public: Io_receptor_registry() { } ~Io_receptor_registry() { Io_receptor *receptor; while ((receptor = _receptors.first()) != 0) _receptors.remove(receptor); } void register_receptor(Io_receptor *receptor) { Lock::Guard guard(_receptors_lock); _receptors.insert(receptor); } void unregister_receptor(Io_receptor *receptor) { Lock::Guard guard(_receptors_lock); _receptors.remove(receptor); } Io_receptor *first() { return _receptors.first(); } }; } #endif /* _NOUX__IO_RECEPTOR_REGISTRY_H_ */