0.0
No commit activity in last 3 years
No release in over 3 years
Semaphore (mutex) like primitive for synchronizing callbacks.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0
>= 1.5.2
>= 0.12.3
 Project Readme

Callback Locker

"Locker" is lockable box for equipment -- at this case box for collecting the callbacks (in its locked state) and running them after unlocking. So, in fact, it serves as some kind of callback semaphore or mutex.

Some trivial example:

require "callback-locker"
locker = CallbackLocker::new

foo = nil
locker.synchronize do
    foo = "bar"
end

# ^^^ locker is unlocked, so #synchronize will execute callback
#     immediately

foo = nil
locker.lock!
locker.synchronize do
    foo = "1"
end
locker.synchronize do
    foo << "2"
end
locker.unlock!

# ^^^ locker is locked, so callbacks are stacked and executed
#     immediately after the #unlock! method is call, so foo
#     will contain "12"

Copyright

Copyright © 2011 – 2015 Martin Poljak. See LICENSE.txt for further details.