/* * Copyright (c) 2018-2020, sin-ack * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include namespace Core { class DeferredInvocationContext final : public Core::EventReceiver { C_OBJECT(DeferredInvocationContext) public: bool should_invoke() const { return m_condition(); } private: DeferredInvocationContext() : m_condition([] { return true; }) { } DeferredInvocationContext(Function condition) : m_condition(move(condition)) { } Function m_condition; }; }