Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,6 @@
require 'mutex_m'
class SomethingWithMutex
include Mutex_m
...
end

View file

@ -0,0 +1,2 @@
an_object = Object.new
an_object.extend(Mutex_m)

View file

@ -0,0 +1,16 @@
# acquire a lock -- block execution until it becomes free
an_object.mu_lock
# acquire a lock -- return immediately even if not acquired
got_lock = an_object.mu_try_lock
# have a lock?
if an_object.mu_locked? then ...
# release the lock
an_object.mu_unlock
# wrap a lock around a block of code -- block execution until it becomes free
an_object.my_synchronize do
do critical stuff
end