App-Context

 view release on metacpan or  search on metacpan

lib/App/ResourceLocker/IPCLocker.pm  view on Meta::CPAN


#############################################################################
## $Id: IPCLocker.pm 6783 2006-08-11 17:43:28Z spadkins $
#############################################################################

package App::ResourceLocker::IPCLocker;
$VERSION = (q$Revision: 6783 $ =~ /(\d[\d\.]*)/)[0];  # VERSION numbers generated by svn

use App;
use App::ResourceLocker;
@ISA = ( "App::ResourceLocker" );

use IPC::::Locker;

use strict;

=head1 NAME

App::ResourceLocker::IPCLocker - locking shared resources using IPC::Locker

=head1 SYNOPSIS

    use App;

    $context = App->context();
    $srs = $context->service("ResourceLocker");  # or ...
    $srs = $context->shared_resource_set();

=head1 DESCRIPTION

A ResourceLocker service represents a collection of "advisory"
(or "cooperative")
resource locks.  The IPCLocker implementation uses the IPC::Locker
distribution available on CPAN.  Locking is implemented by a Locker Daemon
(lockerd), so that locking may be effectively achieved across an entire
network.

=cut

#############################################################################
# CLASS
#############################################################################

=head1 Class: App::ResourceLocker::IPCLocker

A ResourceLocker service represents a collection of "advisory" (or "cooperative")
resource locks.  These can be used to synchronize access to and modification
of shared resources such as are stored in a SharedDatastore.

 * Throws: App::Exception::ResourceLocker
 * Since:  0.01

The ResourceLocker may be configured with the following parameters, which govern
all locks accessed in the ResourceLocker (as per IPC::Locker).

    family      IPC (fifo) family to communicate with the lock server
                INET: use TCP/IP networking
                UNIX: use Unix named pipes (created with "mknod p /path/to/fifo")
                default: INET
    host        default: localhost (only needed for INET family)
    port        default for INET: 1751 (or as defined in /etc/services for "lockerd")
                default for UNIX: /var/locks/lockerd
    timeout     Time at which the server will release the lock if not explicitly
                unlocked by then
                default: 600 sec (10 min) (0 is "unlimited")
    autounlock  Allow the locker daemon to break the lock if the locking process
                is no longer running. (Note that there is an implicit promise
                that the locking process is running on the same server as the
                locker daemon.)
    random      Lock a random resource from the pool when a pool is specified

=cut

#############################################################################
# CONSTRUCTOR METHODS
#############################################################################

=head1 Constructor Methods:

=cut

#############################################################################
# new()
#############################################################################

=head2 new()

The constructor is inherited from
L<C<App::Service>|App::Service/"new()">.

=cut

#############################################################################
# PUBLIC METHODS
#############################################################################

=head1 Public Methods:

=cut

#############################################################################
# lock()
#############################################################################

=head2 lock()

    * Signature: $resource_name = $srs->lock($resource_pool);



( run in 0.618 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )