thread 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/thread/future.rb +5 -2
- data/thread.gemspec +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 513a028c21896bab77d841a86a9b107ee7fee6e1
|
4
|
+
data.tar.gz: bec1675936f02f186c63683df4b55cc19036ddb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 719c2e53adb63973a2fab8d87ee7c9d1924731f5405bf47f15b463be8694ef4232c8bccec89ea089534de845389009c3f4bd0da864037c89ebefa74b1532d746
|
7
|
+
data.tar.gz: 62b91fb7bb2b97a92fa5dfe55c50976b6fc641b994af293db071ae0fde4b8f6ea0fd6f39fba8948c8674488fa74a1e8b754adf472e925f2d143b46ec24ddbb1e
|
data/lib/thread/future.rb
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
#++
|
10
10
|
|
11
11
|
require 'thread'
|
12
|
+
require 'weakref'
|
12
13
|
|
13
14
|
# A future is an object that incapsulates a block which is called in a
|
14
15
|
# different thread, upon retrieval the caller gets blocked until the block has
|
@@ -34,13 +35,15 @@ class Thread::Future
|
|
34
35
|
|
35
36
|
@thread = pool ? pool.process(&task) : Thread.new(&task)
|
36
37
|
|
37
|
-
ObjectSpace.define_finalizer self, self.class.finalizer(@thread)
|
38
|
+
ObjectSpace.define_finalizer self, self.class.finalizer(WeakRef.new(@thread))
|
38
39
|
end
|
39
40
|
|
40
41
|
# @private
|
41
42
|
def self.finalizer(thread)
|
42
43
|
proc {
|
43
|
-
thread.
|
44
|
+
if thread.weakref_alive?
|
45
|
+
thread.raise Cancel.new
|
46
|
+
end
|
44
47
|
}
|
45
48
|
end
|
46
49
|
|
data/thread.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "thread"
|
7
|
-
spec.version = "0.2.
|
7
|
+
spec.version = "0.2.1"
|
8
8
|
spec.authors = ["meh."]
|
9
9
|
spec.email = ["meh@schizofreni.co"]
|
10
10
|
spec.summary = %q{Various extensions to the base thread library.}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thread
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- meh.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -102,4 +102,3 @@ test_files:
|
|
102
102
|
- spec/thread/pipe_spec.rb
|
103
103
|
- spec/thread/pool_spec.rb
|
104
104
|
- spec/thread/promise_spec.rb
|
105
|
-
has_rdoc:
|