]> git.vpit.fr Git - perl/modules/IPC-MorseSignals.git/blobdiff - lib/IPC/MorseSignals/Emitter.pm
Put each POD sentence on its own line
[perl/modules/IPC-MorseSignals.git] / lib / IPC / MorseSignals / Emitter.pm
index a45735cabc97e55f619f55276f9355ecd52de47f..7a4c3d6da05348b6919e9cf799991fe70d068b18 100644 (file)
@@ -16,23 +16,23 @@ IPC::MorseSignals::Emitter - Base class for IPC::MorseSignals emitters.
 
 =head1 VERSION
 
-Version 0.11
+Version 0.16
 
 =cut
 
-our $VERSION = '0.11';
+our $VERSION = '0.16';
 
 =head1 SYNOPSIS
 
     use IPC::MorseSignals::Emitter;
 
-    my $deuce = new IPC::MorseSignals::Emitter speed => 1024;
+    my $deuce = IPC::MorseSignals::Emitter->new(speed => 1024);
     $deuce->post('HLAGH') for 1 .. 3;
     $deuce->send($pid);
 
 =head1 DESCRIPTION
 
-This module sends messages processed by a L<Bit::MorseSignal> emitter to another process as C<SIGUSR1> (for bits 0) and C<SIGUSR2> (for 1) signals.
+This module sends messages processed by an underlying L<Bit::MorseSignal> emitter to another process as a sequence of C<SIGUSR1> (for bits 0) and C<SIGUSR2> (for 1) signals.
 
 =cut
 
@@ -43,9 +43,18 @@ sub _check_self {
 
 =head1 METHODS
 
-=head2 C<< new < delay => $seconds, speed => $bauds, %bme_options > >>
+=head2 C<new>
 
-Creates a new emitter object. C<delay> specifies the delay between two sends, in seconds, while C<speed> is the number of bits sent per second. The delay value has priority over the speed. Extra arguments are passed to L<Bit::MorseSignals::Emitter/new>.
+    my $ime = IPC::MorseSignals::Emitter->new(
+     delay => $seconds,
+     speed => $bauds,
+     %bme_options,
+    );
+
+Creates a new emitter object.
+C<delay> specifies the delay between two sends, in seconds, while C<speed> is the number of bits sent per second.
+The delay value has priority over the speed, and defaults to 1 second.
+Extra arguments are passed to L<Bit::MorseSignals::Emitter/new>.
 
 =cut
 
@@ -66,9 +75,11 @@ sub new {
  bless $self, $class;
 }
 
-=head2 C<send $pid>
+=head2 C<send>
+
+    $ime->send($pid);
 
-Sends messages enqueued with L<Bit::MorseSignals::Emitter/post> to the process C<$pid> (or to all the C<@$pid> if C<$pid> is an array reference).
+Sends messages enqueued with L<Bit::MorseSignals::Emitter/post> to the process C<$pid> (or to all the C<@$pid> if C<$pid> is an array reference, in which case duplicated targets are stripped off).
 
 =cut
 
@@ -76,18 +87,23 @@ sub send {
  my ($self, $dest) = @_;
  _check_self($self);
  return unless defined $dest;
- my @dests = grep $_ > 0, ref $dest eq 'ARRAY' ? map int, grep defined, @$dest
-                                               : int $dest;
+ my %count;
+ my @dests = grep $_ > 0 && !$count{$_}++, # Remove duplicates.
+              ref $dest eq 'ARRAY' ? map int, grep defined, @$dest
+                                   : int $dest;
+ return unless @dests;
  while (defined(my $bit = $self->pop)) {
   my @sigs = (SIGUSR1, SIGUSR2);
   my $d = $self->{delay} * 1_000_000;
   $d -= usleep $d while $d > 0;
   kill $sigs[$bit] => @dests;
  }
- return unless @dests;
 }
 
-=head2 C<< delay < $seconds > >>
+=head2 C<delay>
+
+    my $delay = $ime->delay;
+    $ime->delay($seconds);
 
 Returns the current delay in seconds, or set it if an argument is provided.
 
@@ -100,7 +116,10 @@ sub delay {
  return $self->{delay};
 }
 
-=head2 C<< speed < $bauds > >>
+=head2 C<speed>
+
+    my $speed = $ime->speed;
+    $ime->speed($bauds);
 
 Returns the current speed in bauds, or set it if an argument is provided.
 
@@ -141,11 +160,12 @@ For truly useful IPC, search for shared memory, pipes and semaphores.
 
 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
 
-You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince).
+You can contact me by mail or on C<irc.perl.org> (vincent).
 
 =head1 BUGS
 
-Please report any bugs or feature requests to C<bug-ipc-morsesignals-emitter at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPC-MorseSignals>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
+Please report any bugs or feature requests to C<bug-ipc-morsesignals-emitter at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPC-MorseSignals>.
+I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
 
 =head1 SUPPORT
 
@@ -155,7 +175,7 @@ You can find documentation for this module with the perldoc command.
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007-2008 Vincent Pit, all rights reserved.
+Copyright 2007,2008,2013 Vincent Pit, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.