… | |
… | |
118 | JSON is used, then only strings, numbers and arrays and hashes consisting |
118 | JSON is used, then only strings, numbers and arrays and hashes consisting |
119 | of those are allowed (no objects). When Storable is used, then anything |
119 | of those are allowed (no objects). When Storable is used, then anything |
120 | that Storable can serialise and deserialise is allowed, and for the local |
120 | that Storable can serialise and deserialise is allowed, and for the local |
121 | node, anything can be passed. |
121 | node, anything can be passed. |
122 | |
122 | |
123 | =item mon $portid, sub { } |
123 | =item $guard = mon $portid, $cb->() |
124 | |
124 | |
125 | #TODO monitor the given port |
125 | Monitor the given port and call the given callback when the port is |
|
|
126 | destroyed or connection to it's node is lost. |
|
|
127 | |
|
|
128 | #TODO |
126 | |
129 | |
127 | =cut |
130 | =cut |
128 | |
131 | |
129 | sub mon { |
132 | sub mon { |
130 | my ($noderef, $port) = split /#/, shift, 2; |
133 | my ($noderef, $port) = split /#/, shift, 2; |
… | |
… | |
201 | my $cb = shift; |
204 | my $cb = shift; |
202 | my $id = "$AnyEvent::MP::Base::UNIQ." . $AnyEvent::MP::Base::ID++; |
205 | my $id = "$AnyEvent::MP::Base::UNIQ." . $AnyEvent::MP::Base::ID++; |
203 | |
206 | |
204 | $AnyEvent::MP::Base::PORT{$id} = sub { |
207 | $AnyEvent::MP::Base::PORT{$id} = sub { |
205 | &$cb |
208 | &$cb |
206 | and delete $AnyEvent::MP::Base::PORT{$id}; |
209 | and del $id; |
207 | }; |
210 | }; |
208 | |
211 | |
209 | "$NODE#$id" |
212 | "$NODE#$id" |
210 | } |
213 | } |
211 | |
214 | |