3 ## Classic listener/sender paradigm. Handles communication between various
6 ## Usage note: don't pass threads around. Neither thread nor message equality
7 ## is defined beyond standard object equality. For Thread equality, this is
8 ## because of computational cost. But message equality is trivial by comparing
9 ## message ids, so to communicate something about a particular thread, just
10 ## pass a representative message from it instead.
12 ## This assumes that no message will be a part of more than one thread within
13 ## a single "view" (otherwise a message from a thread wouldn't uniquely
14 ## identify it). But that's true.
21 self.class.i_am_the_instance self
24 def register o; @targets[o] = true; end
25 def unregister o; @targets.delete o; end
27 def relay sender, type, *args
28 meth = "handle_#{type}_update".intern
29 @targets.keys.each { |o| o.send meth, sender, *args unless o == sender if o.respond_to? meth }