class interface SIGNAL_1[E]
--
-- See tutorial/signal/signals.txt for usage
--
creation
make
-- Initialize new signal object
ensure
callbacks.is_empty
feature(s) from SIGNAL_1
callbacks: FAST_ARRAY[PROCEDURE[ANY,TUPLE[ANY]]]
index: INTEGER
last: INTEGER
-- work to do while emit is between index and last.
make
-- Initialize new signal object
ensure
callbacks.is_empty
feature(s) from SIGNAL_1
connect (p: PROCEDURE[ANY,TUPLE[ANY]])
-- Connect procedure to be called when signal is emitted
-- See also last_connect_id
require
p /= Void
ensure
not callbacks.is_empty;
last_connect_id = p
emit (val: E)
-- Emit signal, ie. already registred procedure will be called
-- in registration order except if removed by another before.
require
val /= Void
last_connect_id: PROCEDURE[ANY,TUPLE[ANY]]
-- return identifier on the last connect which may be used
-- for disconnect (unregister procedure)
require
not is_empty
ensure
Result /= Void
disconnect (connect_identifier: PROCEDURE[ANY,TUPLE[ANY]])
-- Unregister procedure for this signal. If the same
-- procedure was registred many times, only first is removed.
ensure
old callbacks.fast_has(connect_identifier) implies callbacks.count = old callbacks.count - 1;
old not callbacks.fast_has(connect_identifier) implies callbacks.count = old callbacks.count
is_empty: BOOLEAN
-- return True if no callback is registred for this signal
invariant
callbacks /= Void;
end of SIGNAL_1[E]