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

Comparing AnyEvent-MP/MP.pm (file contents):
Revision 1.120 by root, Sun Feb 26 11:12:54 2012 UTC vs.
Revision 1.121 by root, Tue Feb 28 18:37:24 2012 UTC

175 175
176=cut 176=cut
177 177
178package AnyEvent::MP; 178package AnyEvent::MP;
179 179
180use AnyEvent::MP::Config ();
180use AnyEvent::MP::Kernel; 181use AnyEvent::MP::Kernel;
182use AnyEvent::MP::Kernel qw(%NODE %PORT %PORT_DATA $UNIQ $RUNIQ $ID);
181 183
182use common::sense; 184use common::sense;
183 185
184use Carp (); 186use Carp ();
185 187
186use AE (); 188use AE ();
187 189
188use base "Exporter"; 190use base "Exporter";
189 191
190our $VERSION = '1.30'; 192our $VERSION = $AnyEvent::MP::Config::VERSION;
191 193
192our @EXPORT = qw( 194our @EXPORT = qw(
193 NODE $NODE *SELF node_of after 195 NODE $NODE *SELF node_of after
194 configure 196 configure
195 snd rcv mon mon_guard kil psub peval spawn cal 197 snd rcv mon mon_guard kil psub peval spawn cal
221Before a node can talk to other nodes on the network (i.e. enter 223Before a node can talk to other nodes on the network (i.e. enter
222"distributed mode") it has to configure itself - the minimum a node needs 224"distributed mode") it has to configure itself - the minimum a node needs
223to know is its own name, and optionally it should know the addresses of 225to know is its own name, and optionally it should know the addresses of
224some other nodes in the network to discover other nodes. 226some other nodes in the network to discover other nodes.
225 227
226The key/value pairs are basically the same ones as documented for the
227F<aemp> command line utility (sans the set/del prefix).
228
229This function configures a node - it must be called exactly once (or 228This function configures a node - it must be called exactly once (or
230never) before calling other AnyEvent::MP functions. 229never) before calling other AnyEvent::MP functions.
230
231The key/value pairs are basically the same ones as documented for the
232F<aemp> command line utility (sans the set/del prefix), with two additions:
233
234=over 4
235
236=item norc => $boolean (default false)
237
238If true, then the rc file (e.g. F<~/.perl-anyevent-mp>) will I<not>
239be consulted - all configuraiton options must be specified in the
240C<configure> call.
241
242=item force => $boolean (default false)
243
244IF true, then the values specified in the C<configure> will take
245precedence over any values configured via the rc file. The default is for
246the rc file to override any options specified in the program.
247
248=back
231 249
232=over 4 250=over 4
233 251
234=item step 1, gathering configuration from profiles 252=item step 1, gathering configuration from profiles
235 253
367sub _kilme { 385sub _kilme {
368 die "received message on port without callback"; 386 die "received message on port without callback";
369} 387}
370 388
371sub port(;&) { 389sub port(;&) {
372 my $id = "$UNIQ." . $ID++; 390 my $id = "$UNIQ." . ++$ID;
373 my $port = "$NODE#$id"; 391 my $port = "$NODE#$id";
374 392
375 rcv $port, shift || \&_kilme; 393 rcv $port, shift || \&_kilme;
376 394
377 $port 395 $port
764} 782}
765 783
766sub spawn(@) { 784sub spawn(@) {
767 my ($nodeid, undef) = split /#/, shift, 2; 785 my ($nodeid, undef) = split /#/, shift, 2;
768 786
769 my $id = "$RUNIQ." . $ID++; 787 my $id = "$RUNIQ." . ++$ID;
770 788
771 $_[0] =~ /::/ 789 $_[0] =~ /::/
772 or Carp::croak "spawn init function must be a fully-qualified name, caught"; 790 or Carp::croak "spawn init function must be a fully-qualified name, caught";
773 791
774 snd_to_func $nodeid, "AnyEvent::MP::_spawn" => $id, @_; 792 snd_to_func $nodeid, "AnyEvent::MP::_spawn" => $id, @_;
775 793
776 "$nodeid#$id" 794 "$nodeid#$id"
777} 795}
796
778 797
779=item after $timeout, @msg 798=item after $timeout, @msg
780 799
781=item after $timeout, $callback 800=item after $timeout, $callback
782 801

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines