Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
signal.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "export.hpp"
4#include "slot.hpp"
5#include <atomic>
6#include <cstddef>
7#include <cstdint>
8#include <memory>
9#include <mutex>
10#include <vector>
11
12namespace aria::abi {
13
20public:
23
24 SignalErased(const SignalErased&) = delete;
27 SignalErased& operator=(SignalErased&&) noexcept;
28
31
34 void disconnect(SlotId id) noexcept;
35
38 void emit(void* args) const;
39
41 [[nodiscard]] std::size_t slot_count() const noexcept;
42
44 void clear() noexcept;
45
46 // ── Internal: weak control-block handle (used for safe disconnect) ──
47 struct ControlBlock;
48 [[nodiscard]] std::weak_ptr<ControlBlock> weak_handle() const noexcept;
49
54 const std::weak_ptr<ControlBlock>& weak,
55 SlotId id) noexcept;
56
57private:
58 std::shared_ptr<ControlBlock> cb_;
59};
60
61} // namespace aria::abi
std::size_t slot_count() const noexcept
Number of currently connected slots.
SlotId connect(SlotErased slot)
Add a slot. Returns its id (used for disconnection).
SignalErased & operator=(const SignalErased &)=delete
void clear() noexcept
Drop all slots, releasing captures outside the signal lock.
SignalErased(SignalErased &&) noexcept
void emit(void *args) const
Emit to all slots.
void disconnect(SlotId id) noexcept
Disconnect by id.
SignalErased(const SignalErased &)=delete
static void disconnect_via_weak(const std::weak_ptr< ControlBlock > &weak, SlotId id) noexcept
Disconnect a slot via a weak handle to the signal's control block — used by Subscription's RAII delet...
std::weak_ptr< ControlBlock > weak_handle() const noexcept
Type-erased callback wrapper.
Definition slot.hpp:35
#define ARIA_ABI_API
Definition export.hpp:21
Definition signal.hpp:12
Definition validation_key.hpp:110
Opaque slot identifier returned when a callback is registered with a Signal.
Definition slot.hpp:12