2021-08-30 10:43:28 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, sin-ack <sin-ack@protonmail.com>
|
2022-02-26 09:09:45 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2021-08-30 10:43:28 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-08-06 18:09:39 +02:00
|
|
|
#include <LibCore/EventReceiver.h>
|
2021-08-30 10:43:28 +00:00
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
2023-08-06 18:09:39 +02:00
|
|
|
class DeferredInvocationContext final : public Core::EventReceiver {
|
2021-08-30 10:43:28 +00:00
|
|
|
C_OBJECT(DeferredInvocationContext)
|
2024-05-08 20:08:18 +02:00
|
|
|
public:
|
|
|
|
bool should_invoke() const { return m_condition(); }
|
|
|
|
|
2021-08-30 10:43:28 +00:00
|
|
|
private:
|
2024-05-08 20:08:18 +02:00
|
|
|
DeferredInvocationContext()
|
|
|
|
: m_condition([] { return true; })
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeferredInvocationContext(Function<bool()> condition)
|
|
|
|
: m_condition(move(condition))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Function<bool()> m_condition;
|
2021-08-30 10:43:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|