Skip to content

Engine → Core → event.h

event

Syntax

template <typename... Args> class event

Constructors

AccessSignatureDescription
publicevent() = default;
publicevent( event &&) noexcept = default;

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~event() = default;

Variables

AccessNameTypeDefaultDescription
privatemStatestd::shared_ptr<state>std::make_shared<state>()

Functions

Public

emit

void emit(
    Args... args) const;

Invokes every live handler in subscription order. Safe to call re-entrantly from a handler, and safe even when a handler destroys this event.

subscribe

[[nodiscard]] event_subscription subscribe(
    handler_type handler);

Registers a handler. The handler runs until the returned subscription is released or destroyed. An empty handler asserts and yields an inactive subscription.

subscriber_count

[[nodiscard]] usize subscriber_count() const noexcept;

Number of live subscriptions, including ones made during a running emit.

Private

ensure_state

void ensure_state();

Operator Overloads

Public

operator=

event &operator=(
    event &&) noexcept = default;