/* * Copyright (c) 2018 Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include #include #include "waitablemanagerbase.hpp" #include "iwaitable.hpp" #include "hossynch.hpp" class IWaitable; class WaitableManager : public WaitableManagerBase { protected: std::vector to_add_waitables; std::vector waitables; u64 timeout = 0; HosMutex lock; std::atomic_bool has_new_items = false; private: void process_internal(bool break_on_timeout); public: WaitableManager(u64 t) : timeout(t) { } ~WaitableManager() override { /* This should call the destructor for every waitable. */ std::for_each(waitables.begin(), waitables.end(), std::default_delete{}); } virtual void add_waitable(IWaitable *waitable); virtual void process(); virtual void process_until_timeout(); };