lockstep 0.0.2 → 0.0.3

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: f160923c69a091c21bd3e8cd7609206ad2c2cc1a
4
- data.tar.gz: 630f2dfe39ee1a2ef631a73f0ebc78f2a8991d01
3
+ metadata.gz: a00c3b87ae9f97f313a0cdf45105827d34c4416a
4
+ data.tar.gz: 6a13ad07964ddef07a98d0d694ee6c082c0de2d9
5
5
  SHA512:
6
- metadata.gz: 5b33b19afb2978b2e138a419ca009573955725b231b07d96fadf637714037f8d9f4589bc453e7d8452d2b3fcf439d5bb07f023fc14340148ff5414dbe6f8dd2d
7
- data.tar.gz: 2d1e79b729cf6a5cd4c5cf42a9f539dc609c9fd18553cdc643aa89e2c5d15901306ad89bb5e71937518e72146b5ea8abccc4046202aebce9c1d943590f74687a
6
+ metadata.gz: b7e672c9ba57dd1c723d5ac4b785a9d1c165d54512a24bce22f155522cd999a749e0b741338ae81198bb1aa77cfafb5de5a58fe6aecc51678b8eb19d1b53cdae
7
+ data.tar.gz: ce5bd877738e0f91ee2893832a922414945b8fbc38c88d370e0d80655b7556af45bb7ae37c3030322625c9efcb58ea807e6e0767322585e4929a86b96e7393b5
@@ -1,8 +1,15 @@
1
+ require 'forwardable'
2
+
1
3
  class SyncThread
4
+ extend Forwardable
5
+
2
6
  def self.interrupt(source, name, *args, &block)
3
7
  Fiber.yield(:interrupt, source, name, args, block)
4
8
  end
5
9
 
10
+ attr_reader :status
11
+ def_delegators :status, :interrupted?, :interrupted_by?, :finished?
12
+
6
13
  def initialize
7
14
  @status = Started.new
8
15
  @fiber = Fiber.new do
@@ -36,6 +43,10 @@ class SyncThread
36
43
  resume(ignore: true)
37
44
  end
38
45
 
46
+ def last_return_value
47
+ status.return_value
48
+ end
49
+
39
50
  private
40
51
 
41
52
  def execute(options={})
@@ -58,13 +69,17 @@ class SyncThread
58
69
 
59
70
  class Started
60
71
  def finished?; true; end
72
+ def interrupted?; false; end
73
+ def interrupted_by?(*); false; end
61
74
  end
62
75
  Finished = Struct.new(:return_value) do
63
76
  def finished?; true; end
77
+ def interrupted?; false; end
64
78
  def interrupted_by?(*); false; end
65
79
  end
66
80
  Interrupted = Struct.new(:source, :name, :arguments, :block) do
67
81
  def finished?; false; end
82
+ def interrupted?; true; end
68
83
  def interrupted_by?(source_or_message, message=nil, args=nil)
69
84
  if args
70
85
  return false unless args === arguments
@@ -1,3 +1,3 @@
1
1
  module Lockstep
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockstep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avdi Grimm