Recommendations on Locking/SharedMem/IPC modules

[email protected] (Stephen Adkins)
Newsgroups perl.p5ee
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.