AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ACutoffSignal.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13
14#include "AMutex.h"
15#include "AConditionVariable.h"
16
23class [[deprecated("Use AFuture<void> instead")]] ACutoffSignal {
24public:
25 ACutoffSignal() = default;
26
30 void makeSignal() {
31 std::unique_lock lock(mMutex);
32 mSignaled = true;
33 mCV.notify_all();
34 }
35
39 void resetSignal() noexcept {
40 mSignaled = false;
41 }
42
52 if (!mSignaled) {
53 std::unique_lock lock(mMutex);
54 mCV.wait(lock, [this] {
55 return mSignaled;
56 });
57 }
58 }
59
60private:
61 AMutex mMutex;
63 bool mSignaled = false;
64};
65
66
Represents a condition variable.
Definition AConditionVariable.h:24
void resetSignal() noexcept
Resets the cut off state so the waitForSignal() function would block again.
Definition ACutoffSignal.h:39
void makeSignal()
Flags a signal, causing the waitForSignal() to never block.
Definition ACutoffSignal.h:30
void waitForSignal()
Wait for makeSignal().
Definition ACutoffSignal.h:51
Basic syscall-based synchronization primitive.
Definition AMutex.h:33