AnyEvent-FileLock
view release on metacpan or search on metacpan
lib/AnyEvent/FileLock.pm view on Meta::CPAN
to obtain the lock under the hood.
The default is C<flock>.
In order to use locks of type C<fcntl>, the module L<Fctnl::Packer>
has to be also installed.
=item cb => $sub_ref
The given function is called once the lock is acquired on the
file with the file handle passed as an argument.
In case of error (i.e. timeout) C<undef> will be passed instead of the
file handle. The error can be retrieved from C<$!>.
The user is responsible for closing the file handle or calling
C<flock($fh, LOCK_UN)> (or the corresponding L<fcntl(2)> F<F_UNLCK>)
on it when required.
=item open_mode => $mode
The mode used to open the file when the argument C<file> is
passed. Accepted values are C<< < >>, C<< > >>, C<<< >> >>>, C<< +< >>
and C<< +> >>.
=item lock_mode => $mode
The mode used when locking the file, it accepts the same set of values
as C<open_mode>. C<< < >> means shared access and everything else
exclusive access.
=item mode => $mode
Configures both C<open_mode> and C<lock_mode>.
=item timeout => $seconds
The operation is aborted if the lock operation can not be completed
for the given lapse.
Note that this timeout is approximate, it is checked just after every
failed locking attempt.
=item delay => $seconds
Time to be delayed between consecutive locking attempts. Defaults to 1
second.
Some randomness will be added to the delay to avoid the degenerate
case where all the contenders look for the lock at the same time
every time.
=item whence => $whence
=item start => $start
=item len => $len
When C<fcntl> is selected as the lock type, this three additional
arguments can be used to define the section of the file that has to be
locked. See L<fcntl(2)> for the details.
=back
=head1 SEE ALSO
L<AnyEvent>.
L<perlfunc/flock>, L<perlfunc/fcntl>, L<fcntl(2)>, L<Fcntl>,
L<Fcntl::Packer>.
=head1 AUTHORS
Salvador FandiE<ntilde>o, E<lt>sfandino@yahoo.comE<gt>
Manfred Stock, E<lt>mstock@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2013, 2017 by Qindel FormaciE<oacute>n y Servicios S.L.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.14.2 or,
at your option, any later version of Perl 5 you may have available.
=cut
( run in 0.648 second using v1.01-cache-2.11-cpan-e1769b4cff6 )