-
Notifications
You must be signed in to change notification settings - Fork 1
inter-process synchronization primitives using shared memory
ice799/shlock
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
What is shlock ? =============== shlock is a library that provides synchronization primitives that use shared memory. Currently, mutexes (Shlock::Putex) and rwlocks (Shlock::Prwlock) are implemented. Why ? ===== If want to synchronize two ruby processes without using those painful file locks, you can use this. TODO ==== - It is probably not safe to use these pthread exposed APIs in this way. I should probably reimplement the low-level locking primitives in C using atomic.h and futexes. - Add documentation about Shlock::Prwlock Sample Usage of Shlock::Putex ============================= process1.rb: require 'shlock' f = Shlock::Putex.new("/test-mutex") f.lock puts("locked the mutex once, grabbing lock again to spin-wait; go run process2.rb once locked up...\n") f.lock puts("got the lock, exiting\n") process2.rb: require 'shlock' f = Shlock::Putex.new("/text-mutex") puts "alive, unlocking" f.unlock puts "done, exiting" f.destroy in your terminal: % ruby process1.rb when it tells you to run process2.rb, in another terminal enter: % ruby process2.rb you should see process2 unlock process1 and allow it to exit. What's next ? ============= Maybe some more process-to-process synchronization primitives?
About
inter-process synchronization primitives using shared memory
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published