Hi,

I am looking for recommendations for modules which handle
cooperative resource locking across processes (similar to
semaphores in Unix).

"Cooperative" is in contrast to something like "flock"
where the operating system knows about the resource being
locked and can actually enforce the locking.

i.e.

    use XYZ::LockSet;

    $lockset = XYZ::LockSet->new(... args ...);

    $lockset->lock($resource);  # blocks until resource is available

    ... do stuff with the resource without interference from other
        threads or processes ...

    $lockset->unlock($resource);

    ...

This would allow you to simulate Java's "synchronize" keyword on a
method by writing methods like this.


    package XYZ::Class;

    sub foo {
        $lockset->lock("XYZ::Class.foo");
        ... do stuff without interference from other threads/processes ...
        $lockset->unlock("XYZ::Class.foo");
    }

Of course, the locking mechanism I envision is more flexible than the 
"synchronize" keyword in Java (I just used it as an illustration).

I am looking into building something on Cache::Cache if I don't get
any better recommendations.

Other valuable recommendations would include:

  * locking which differentiates reading from writing
  * other shared memory style IPC mechanisms

Thanks,

Stephen

Reply via email to