wref 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -4
- data/VERSION +1 -1
- data/lib/wref.rb +13 -13
- data/wref.gemspec +2 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -3,13 +3,12 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
diff-lcs (1.1.3)
|
5
5
|
git (1.2.5)
|
6
|
-
jeweler (1.8.
|
6
|
+
jeweler (1.8.4)
|
7
7
|
bundler (~> 1.0)
|
8
8
|
git (>= 1.2.5)
|
9
9
|
rake
|
10
10
|
rdoc
|
11
|
-
json (1.7.
|
12
|
-
json (1.7.1-java)
|
11
|
+
json (1.7.3)
|
13
12
|
rake (0.9.2.2)
|
14
13
|
rdoc (3.12)
|
15
14
|
json (~> 1.4)
|
@@ -23,7 +22,6 @@ GEM
|
|
23
22
|
rspec-mocks (2.8.0)
|
24
23
|
|
25
24
|
PLATFORMS
|
26
|
-
java
|
27
25
|
ruby
|
28
26
|
|
29
27
|
DEPENDENCIES
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/wref.rb
CHANGED
@@ -135,7 +135,7 @@ class Wref_map
|
|
135
135
|
|
136
136
|
#JRuby cant handle this atm... Dunno why...
|
137
137
|
if RUBY_ENGINE != "jruby"
|
138
|
-
ObjectSpace.define_finalizer(obj, self.method(
|
138
|
+
ObjectSpace.define_finalizer(obj, self.method(:delete_by_id))
|
139
139
|
end
|
140
140
|
|
141
141
|
return nil
|
@@ -151,10 +151,13 @@ class Wref_map
|
|
151
151
|
# end
|
152
152
|
def get(id)
|
153
153
|
begin
|
154
|
+
wref = nil
|
154
155
|
@mutex.synchronize do
|
155
156
|
raise Wref::Recycled if !@map.key?(id)
|
156
|
-
|
157
|
+
wref = @map[id]
|
157
158
|
end
|
159
|
+
|
160
|
+
return wref.get
|
158
161
|
rescue Wref::Recycled => e
|
159
162
|
self.delete(id)
|
160
163
|
raise e
|
@@ -195,13 +198,13 @@ class Wref_map
|
|
195
198
|
def valid?(key)
|
196
199
|
@mutex.synchronize do
|
197
200
|
return false if !@map.key?(key)
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
201
|
+
end
|
202
|
+
|
203
|
+
begin
|
204
|
+
@map[key].get
|
205
|
+
return true
|
206
|
+
rescue Wref::Recycled
|
207
|
+
return false
|
205
208
|
end
|
206
209
|
end
|
207
210
|
|
@@ -224,10 +227,7 @@ class Wref_map
|
|
224
227
|
#Cleans the hash and returns the length. This is slower but more accurate than the ordinary length that just returns the hash-length.
|
225
228
|
def length_valid
|
226
229
|
self.clean
|
227
|
-
|
228
|
-
@mutex.synchronize do
|
229
|
-
return @map.length
|
230
|
-
end
|
230
|
+
return self.length
|
231
231
|
end
|
232
232
|
|
233
233
|
#Deletes a key in the hash.
|
data/wref.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{wref}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
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"]
|
12
|
-
s.date = %q{2012-07-
|
12
|
+
s.date = %q{2012-07-24}
|
13
13
|
s.description = %q{Lightweight weak reference and weak hash that works in 1.9 and JRuby.}
|
14
14
|
s.email = %q{k@spernj.org}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: wref
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-24 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
hash:
|
96
|
+
hash: 1899504982320509212
|
97
97
|
segments:
|
98
98
|
- 0
|
99
99
|
version: "0"
|