thread 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f1ac6a92f77e49dec38a35d8f17c607568f2702
4
- data.tar.gz: 794e057cc2b9ea319f1051e13d7d69f7f61a92dd
3
+ metadata.gz: 513a028c21896bab77d841a86a9b107ee7fee6e1
4
+ data.tar.gz: bec1675936f02f186c63683df4b55cc19036ddb9
5
5
  SHA512:
6
- metadata.gz: a8be737ccd11509f373d5a7c3d78a2e29fc1a0d6d414cac1a357ed4ee0472fa53f753de7f1cc4015cf453db34ddf42441f700c136566c8d17f65ce78a19ec810
7
- data.tar.gz: 30461440ad2c050a41688c12e90bb7ce16df3bd706edb9f51d4bee4dd63dfa906f3e301da044f14be826f28a5ef740f9a2172495a17d6ab2122fb609d31fe2c5
6
+ metadata.gz: 719c2e53adb63973a2fab8d87ee7c9d1924731f5405bf47f15b463be8694ef4232c8bccec89ea089534de845389009c3f4bd0da864037c89ebefa74b1532d746
7
+ data.tar.gz: 62b91fb7bb2b97a92fa5dfe55c50976b6fc641b994af293db071ae0fde4b8f6ea0fd6f39fba8948c8674488fa74a1e8b754adf472e925f2d143b46ec24ddbb1e
@@ -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.raise Cancel.new
44
+ if thread.weakref_alive?
45
+ thread.raise Cancel.new
46
+ end
44
47
  }
45
48
  end
46
49
 
@@ -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.0"
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.0
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-04-09 00:00:00.000000000 Z
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: