Subject: | A non-blocking version of lock() would be nice |
I'd like to use IO::All for a cronjob lockfile. The job will be running every five minutes, and the fact that lock() always blocks means that if a run takes more than five minutes, subsequent runs will stack up behind it, waiting to acquire the lock, which I don't want happening.
I think that a lock_nb() method would be a perfect fit for this use case. E.g.,:
my $lockfile = io("/path/to/file")->assert->lock_nb < "$$" || exit; # Or die() if appropriate
Yes, I could just use flock() directly or another module like Lock::File, but this seems like something IO::All should be able to do. =)