struct Lapis::Core::StaticSignalSlot(*T)

Overview

Stack-allocated, compile-time typed handle to a slot in StaticSignalTable.

Provides zero-allocation emission (#emit(*args : *T)) and direct binding (#bind, #connect, #once, #+, #-).

Defined in:

lapis/core/static_signal_table.cr

Constructors

Instance Method Summary

Instance methods inherited from class Object

try?(&)
try?
try?

Constructor Detail

def self.from_table(table : StaticSignalTable, emitter_id : UInt64, name : String, signal_hash : UInt64) : self #

def self.from_table(table : StaticSignalTable, emitter_id : UInt64, signal_hash : UInt64) : self #

def self.new(name : String = "signal", table : StaticSignalTable = StaticSignalTable.global, emitter_id : UInt64 = StaticSignalTable.next_anonymous_emitter_id) #

Instance Method Detail

def +(callback : Proc(*T, R)) : self forall R #

Compound operator #+ for subscribing a typed Proc(*T, R).


def -(callback : Proc(*T, R)) : self forall R #

Compound operator #- for unbinding a typed Proc(*T, R).


def active_count : Int32 #

Returns the number of active listeners bound to this slot.


def bind(callback : Proc(*T, R), once : Bool = false, subscription : Godot::SignalSubscription | Nil = nil, match_proc_pointer : Pointer(Void) = Pointer(Void).null, match_closure_data : Pointer(Void) = Pointer(Void).null) : UInt64 forall R #

Binds a typed Proc(*T, R) directly to this static signal slot.


def bind(once : Bool = false, &block : *T -> Void) : UInt64 #

Block overload for #bind delegating directly to StaticSignalTable#bind_by_hash.


def clear! : Int32 #

Clears all listeners registered in this slot.


def connect(once : Bool = false, &block : *T -> Void) : UInt64 #

Connects a typed block to this static signal slot.


def connected? : Bool #

Returns true if at least one listener is currently bound to this slot.


def emission_count : UInt64 #

Returns the total number of emissions dispatched through this slot.


def emit(*args : *T) : Int32 #

Emits *args to all active listeners in this slot with zero GC heap allocations.


def emitter_id : UInt64 #

def empty? : Bool #

Returns true if no listeners are currently bound to this slot.


def name : String #

def once(&block : *T -> Void) : UInt64 #

Connects a one-shot typed block that automatically unbinds after its first invocation.


def signal_hash : UInt64 #

def table : StaticSignalTable #

def unbind(callback : Proc(*T, R)) : Bool forall R #

Unbinds the most recently registered listener matching callback.


def unbind(token : UInt64) : Bool #

Unbinds a listener by its 64-bit token.