class interface SIGNAL_2[E,F]
--
-- See tutorial/signal/signals.txt for usage
--
creation
make
-- Initialize new signal object
ensure
callbacks.is_empty
feature(s) from SIGNAL_2
callbacks: FAST_ARRAY[PROCEDURE[ANY,TUPLE[ANY, 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_2
connect (p: PROCEDURE[ANY,TUPLE[ANY, 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 (val1: E; val2: F)
-- Emit signal, ie. already registred procedure will be called
-- in registration order except if removed by another before.
require
val1 /= Void;
val2 /= Void
last_connect_id: PROCEDURE[ANY,TUPLE[ANY, 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, 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_2[E,F]