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 +4 -4
- data/lib/lockstep/sync_thread.rb +15 -0
- data/lib/lockstep/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a00c3b87ae9f97f313a0cdf45105827d34c4416a
|
4
|
+
data.tar.gz: 6a13ad07964ddef07a98d0d694ee6c082c0de2d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7e672c9ba57dd1c723d5ac4b785a9d1c165d54512a24bce22f155522cd999a749e0b741338ae81198bb1aa77cfafb5de5a58fe6aecc51678b8eb19d1b53cdae
|
7
|
+
data.tar.gz: ce5bd877738e0f91ee2893832a922414945b8fbc38c88d370e0d80655b7556af45bb7ae37c3030322625c9efcb58ea807e6e0767322585e4929a86b96e7393b5
|
data/lib/lockstep/sync_thread.rb
CHANGED
@@ -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
|
data/lib/lockstep/version.rb
CHANGED