in reply to Mutex::Flock - Fcntl advisory locking supporting processes and threads.
There is also locks_shared method, but not mentioned in the documentation. You see, this is based on MCE::Mutex.
I wrote this module for Marty O'Brien Forks::Queue, but do not know how to reach him. That module is not threads-safe unforunately and the reason for writing Mutex::Flock as an exercise. Adding support for threads-safety takes little code.
my $has_threads = $INC{'threads.pm'} ? 1 : 0; my $tid = $has_threads ? threads->tid() : 0; sub CLONE { $tid = threads->tid() if $has_threads; }
In the rest of the code, use "$$.$tid" instead of "$$".
Regards, Mario
Edit: I emailed Marty using his CPAN handle.
Edit: Removed the underscore after the sigil in variables.
Edit: Completed module documentation.
|
|---|