X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FIPC%2FMorseSignals%2FEmitter.pm;h=b5ba7e61fc2faaf843af553a01f37b1e2e3ebe67;hb=0b4f6d24128d9d60c3f8a5010e43bdfd9de7b655;hp=940fd16c64e7b09f66b7b02a1a376c7c91257e7f;hpb=66395d4fefdc940dce749d571e5c8106f682eca4;p=perl%2Fmodules%2FIPC-MorseSignals.git diff --git a/lib/IPC/MorseSignals/Emitter.pm b/lib/IPC/MorseSignals/Emitter.pm index 940fd16..b5ba7e6 100644 --- a/lib/IPC/MorseSignals/Emitter.pm +++ b/lib/IPC/MorseSignals/Emitter.pm @@ -16,17 +16,17 @@ IPC::MorseSignals::Emitter - Base class for IPC::MorseSignals emitters. =head1 VERSION -Version 0.13 +Version 0.15 =cut -our $VERSION = '0.13'; +our $VERSION = '0.15'; =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); @@ -45,7 +45,7 @@ sub _check_self { =head2 C<< new < delay => $seconds, speed => $bauds, %bme_options > >> -Creates a new emitter object. C specifies the delay between two sends, in seconds, while C is the number of bits sent per second. The delay value has priority over the speed. Extra arguments are passed to L. +Creates a new emitter object. C specifies the delay between two sends, in seconds, while C is the number of bits sent per second. The delay value has priority over the speed. Default delay is 1 second. Extra arguments are passed to L. =cut @@ -68,7 +68,7 @@ sub new { =head2 C -Sends messages enqueued with L to the process C<$pid> (or to all the C<@$pid> if C<$pid> is an array reference). +Sends messages enqueued with L 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,8 +76,10 @@ 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); @@ -141,7 +143,7 @@ For truly useful IPC, search for shared memory, pipes and semaphores. Vincent Pit, C<< >>, L. -You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince). +You can contact me by mail or on C (vincent). =head1 BUGS