… | |
… | |
183 | |
183 | |
184 | package AnyEvent::MP; |
184 | package AnyEvent::MP; |
185 | |
185 | |
186 | use AnyEvent::MP::Config (); |
186 | use AnyEvent::MP::Config (); |
187 | use AnyEvent::MP::Kernel; |
187 | use AnyEvent::MP::Kernel; |
188 | use AnyEvent::MP::Kernel qw(%NODE %PORT %PORT_DATA $UNIQ $RUNIQ $ID); |
188 | use AnyEvent::MP::Kernel qw( |
|
|
189 | %NODE %PORT %PORT_DATA $UNIQ $RUNIQ $ID |
|
|
190 | add_node load_func |
|
|
191 | |
|
|
192 | NODE $NODE |
|
|
193 | configure |
|
|
194 | node_of port_is_local |
|
|
195 | snd kil |
|
|
196 | db_set db_del |
|
|
197 | db_mon db_family db_keys db_values |
|
|
198 | ); |
189 | |
199 | |
190 | use common::sense; |
200 | use common::sense; |
191 | |
201 | |
192 | use Carp (); |
202 | use Carp (); |
193 | |
203 | |
… | |
… | |
197 | use base "Exporter"; |
207 | use base "Exporter"; |
198 | |
208 | |
199 | our $VERSION = $AnyEvent::MP::Config::VERSION; |
209 | our $VERSION = $AnyEvent::MP::Config::VERSION; |
200 | |
210 | |
201 | our @EXPORT = qw( |
211 | our @EXPORT = qw( |
202 | NODE $NODE *SELF node_of after |
212 | NODE $NODE |
203 | configure |
213 | configure |
|
|
214 | node_of port_is_local |
|
|
215 | snd kil |
|
|
216 | db_set db_del |
|
|
217 | db_mon db_family db_keys db_values |
|
|
218 | |
|
|
219 | *SELF |
|
|
220 | |
204 | snd rcv mon mon_guard kil psub peval spawn cal |
221 | port rcv mon mon_guard psub peval spawn cal |
205 | port |
|
|
206 | db_set db_del db_reg |
222 | db_set db_del db_reg |
207 | db_mon db_family db_keys db_values |
223 | db_mon db_family db_keys db_values |
|
|
224 | |
|
|
225 | after |
208 | ); |
226 | ); |
209 | |
227 | |
210 | our $SELF; |
228 | our $SELF; |
211 | |
229 | |
212 | sub _self_die() { |
230 | sub _self_die() { |
… | |
… | |
222 | a call to C<configure>. |
240 | a call to C<configure>. |
223 | |
241 | |
224 | =item $nodeid = node_of $port |
242 | =item $nodeid = node_of $port |
225 | |
243 | |
226 | Extracts and returns the node ID from a port ID or a node ID. |
244 | Extracts and returns the node ID from a port ID or a node ID. |
|
|
245 | |
|
|
246 | =item $is_local = port_is_local $port |
|
|
247 | |
|
|
248 | Returns true iff the port is a local port. |
227 | |
249 | |
228 | =item configure $profile, key => value... |
250 | =item configure $profile, key => value... |
229 | |
251 | |
230 | =item configure key => value... |
252 | =item configure key => value... |
231 | |
253 | |
… | |
… | |
464 | |
486 | |
465 | sub rcv($@) { |
487 | sub rcv($@) { |
466 | my $port = shift; |
488 | my $port = shift; |
467 | my ($nodeid, $portid) = split /#/, $port, 2; |
489 | my ($nodeid, $portid) = split /#/, $port, 2; |
468 | |
490 | |
469 | $NODE{$nodeid} == $NODE{""} |
491 | $nodeid eq $NODE |
470 | or Carp::croak "$port: rcv can only be called on local ports, caught"; |
492 | or Carp::croak "$port: rcv can only be called on local ports, caught"; |
471 | |
493 | |
472 | while (@_) { |
494 | while (@_) { |
473 | if (ref $_[0]) { |
495 | if (ref $_[0]) { |
474 | if (my $self = $PORT_DATA{$portid}) { |
496 | if (my $self = $PORT_DATA{$portid}) { |