No commit activity in last 3 years
No release in over 3 years
Adds a flock_synchronize method that synchronizes code execution between processes, similar to how a Mutex works between threads.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
>= 0
 Project Readme

FlockSynchronize

This gem allows synchronization of code across multiple processes on POSIX systems using flock, similar to how Mutexes work for Ruby threads.

Wrapping your code in FlockSynchronize.flock_synchronize will create a filesystem lock for a given string key. All processes synchronized with the same key will wait for each other.

For example:

FlockSynchronize.flock_synchronize("mykey") do
   some_code_that_needs_to_be_synchronized()
end

Note: This only works with multiple processes, and not with multiple Ruby threads. If you want the same behaviour with threads, look at the built-in Mutex class.

Installation

Add this line to your application's Gemfile:

gem 'flock_synchronize'

And then execute:

$ bundle

Or install it yourself as:

$ gem install flock_synchronize

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fishpercolator/flock_synchronize