=head1 VERSION
-Version 0.11
+Version 0.15
=cut
-our $VERSION = '0.11';
+our $VERSION = '0.15';
=head1 SYNOPSIS
=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
=head2 C<< 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. Extra arguments are passed to L<Bit::MorseSignals::Emitter/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. Default delay is 1 second. Extra arguments are passed to L<Bit::MorseSignals::Emitter/new>.
=cut
=head2 C<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
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 > >>