ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/AnyEvent-MP/MP.pm
(Generate patch)

Comparing cvsroot/AnyEvent-MP/MP.pm (file contents):
Revision 1.143 by root, Fri Mar 23 17:54:36 2012 UTC vs.
Revision 1.145 by root, Tue Oct 2 13:58:07 2012 UTC

183 183
184package AnyEvent::MP; 184package AnyEvent::MP;
185 185
186use AnyEvent::MP::Config (); 186use AnyEvent::MP::Config ();
187use AnyEvent::MP::Kernel; 187use AnyEvent::MP::Kernel;
188use AnyEvent::MP::Kernel qw(%NODE %PORT %PORT_DATA $UNIQ $RUNIQ $ID); 188use 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
190use common::sense; 200use common::sense;
191 201
192use Carp (); 202use Carp ();
193 203
197use base "Exporter"; 207use base "Exporter";
198 208
199our $VERSION = $AnyEvent::MP::Config::VERSION; 209our $VERSION = $AnyEvent::MP::Config::VERSION;
200 210
201our @EXPORT = qw( 211our @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
210our $SELF; 228our $SELF;
211 229
212sub _self_die() { 230sub _self_die() {
223 241
224=item $nodeid = node_of $port 242=item $nodeid = node_of $port
225 243
226Extracts and returns the node ID from a port ID or a node ID. 244Extracts and returns the node ID from a port ID or a node ID.
227 245
246=item $is_local = port_is_local $port
247
248Returns true iff the port is a local port.
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
232Before a node can talk to other nodes on the network (i.e. enter 254Before a node can talk to other nodes on the network (i.e. enter
243=over 4 265=over 4
244 266
245=item norc => $boolean (default false) 267=item norc => $boolean (default false)
246 268
247If true, then the rc file (e.g. F<~/.perl-anyevent-mp>) will I<not> 269If true, then the rc file (e.g. F<~/.perl-anyevent-mp>) will I<not>
248be consulted - all configuraiton options must be specified in the 270be consulted - all configuration options must be specified in the
249C<configure> call. 271C<configure> call.
250 272
251=item force => $boolean (default false) 273=item force => $boolean (default false)
252 274
253IF true, then the values specified in the C<configure> will take 275IF true, then the values specified in the C<configure> will take
464 486
465sub rcv($@) { 487sub 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}) {
518} 540}
519 541
520=item peval $port, $coderef[, @args] 542=item peval $port, $coderef[, @args]
521 543
522Evaluates the given C<$codref> within the contetx of C<$port>, that is, 544Evaluates the given C<$codref> within the contetx of C<$port>, that is,
523when the code throews an exception the C<$port> will be killed. 545when the code throws an exception the C<$port> will be killed.
524 546
525Any remaining args will be passed to the callback. Any return values will 547Any remaining args will be passed to the callback. Any return values will
526be returned to the caller. 548be returned to the caller.
527 549
528This is useful when you temporarily want to execute code in the context of 550This is useful when you temporarily want to execute code in the context of

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines