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 CHANGED
@@ -1 +1 @@
1
- 0.0.2
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
- @tsafe_rwmutex = Tsafe::Mrswlock.new
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
- @tsafe_rwmutex.rsync do
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
- @tsafe_rwmutex.wsync do
78
+ @tsafe_mrswlock.wsync do
68
79
  return self.__send__(newmname, *args, &block)
69
80
  end
70
81
  end
@@ -12,6 +12,14 @@ describe "Tsafe::Rwmutex" do
12
12
  hash[realcount] = realcount
13
13
  end
14
14
 
15
+ hash._tsafe_rsync do
16
+
17
+ end
18
+
19
+ hash._tsafe_wsync do
20
+
21
+ end
22
+
15
23
  ts = []
16
24
 
17
25
  1.upto(20) do |tcount|
data/tsafe.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tsafe}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tsafe
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
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: -2173245037077318773
103
+ hash: 1681009258934768204
104
104
  segments:
105
105
  - 0
106
106
  version: "0"