tsafe 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/include/mrswlock.rb +14 -3
- data/spec/mrswlock_spec.rb +8 -0
- data/tsafe.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/include/mrswlock.rb
CHANGED
@@ -40,11 +40,22 @@ class Tsafe::Mrswlock
|
|
40
40
|
module SynModule
|
41
41
|
def self.included(base)
|
42
42
|
base.to_s.split("::").inject(Object, :const_get).class_eval do
|
43
|
+
#Yields the given block within the read-lock.
|
44
|
+
def _tsafe_rsync(&block)
|
45
|
+
@tsafe_mrswlock.rsync(&block)
|
46
|
+
end
|
47
|
+
|
48
|
+
#Yields the given block within the write-lock (and read-lock).
|
49
|
+
def _tsafe_wsync(&block)
|
50
|
+
@tsafe_mrswlock.rsync(&block)
|
51
|
+
end
|
52
|
+
|
43
53
|
#Rename initialize.
|
44
54
|
alias_method(:initialize_rwmutex, :initialize)
|
45
55
|
|
56
|
+
#Make another initialize-method that spawns the lock and then calls the original initialize.
|
46
57
|
define_method(:initialize) do |*args, &block|
|
47
|
-
@
|
58
|
+
@tsafe_mrswlock = Tsafe::Mrswlock.new
|
48
59
|
return initialize_rwmutex(*args, &block)
|
49
60
|
end
|
50
61
|
|
@@ -53,7 +64,7 @@ class Tsafe::Mrswlock
|
|
53
64
|
alias_method(newmname, mname)
|
54
65
|
|
55
66
|
define_method(mname) do |*args, &block|
|
56
|
-
@
|
67
|
+
@tsafe_mrswlock.rsync do
|
57
68
|
return self.__send__(newmname, *args, &block)
|
58
69
|
end
|
59
70
|
end
|
@@ -64,7 +75,7 @@ class Tsafe::Mrswlock
|
|
64
75
|
alias_method(newmname, mname)
|
65
76
|
|
66
77
|
define_method(mname) do |*args, &block|
|
67
|
-
@
|
78
|
+
@tsafe_mrswlock.wsync do
|
68
79
|
return self.__send__(newmname, *args, &block)
|
69
80
|
end
|
70
81
|
end
|
data/spec/mrswlock_spec.rb
CHANGED
data/tsafe.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tsafe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
hash:
|
103
|
+
hash: 1681009258934768204
|
104
104
|
segments:
|
105
105
|
- 0
|
106
106
|
version: "0"
|