futuroscope 0.0.8 → 0.0.9
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/futuroscope/future.rb +7 -12
- data/lib/futuroscope/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: 4e066ddbe361ebf3572172f07fbb8a8f01aa19ad
|
4
|
+
data.tar.gz: d087e61fd2f458e3ad9b4013f5d2fbdd68de6b8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1691e432210c6caa0275a4961972fef07de521909d4f7eb6d105bcfbc2d652d4f63e99e8cb5290d59efb9cde2fe31b8ec794c98c26694a9808f485cd1a2052a3
|
7
|
+
data.tar.gz: bc7302b1ebe5f7301fb18b5710ad2db5dd8d9c8e3f6d14034dfe57a4b8d1516b408e0e5bba00c49988d039c36de1fbe8a7ca376eff5061e98adeff1905043e18
|
data/lib/futuroscope/future.rb
CHANGED
@@ -5,7 +5,6 @@ module Futuroscope
|
|
5
5
|
# and will return it instantly if the thread's execution already finished.
|
6
6
|
#
|
7
7
|
class Future
|
8
|
-
attr_writer :future_value
|
9
8
|
extend Forwardable
|
10
9
|
|
11
10
|
# Initializes a future with a block and starts its execution.
|
@@ -32,12 +31,14 @@ module Futuroscope
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def run_future
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
@mutex.synchronize do
|
35
|
+
begin
|
36
|
+
@future_value = @block.call
|
37
|
+
rescue Exception => e
|
38
|
+
@exception = e
|
39
|
+
end
|
40
|
+
@condition.signal
|
39
41
|
end
|
40
|
-
@condition.signal
|
41
42
|
end
|
42
43
|
|
43
44
|
# Semipublic: Returns the future's value. Will wait for the future to be
|
@@ -66,11 +67,5 @@ module Futuroscope
|
|
66
67
|
def respond_to_missing?(method, include_private = false)
|
67
68
|
future_value.respond_to?(method, include_private)
|
68
69
|
end
|
69
|
-
|
70
|
-
def future_value=(value)
|
71
|
-
@mutex.synchronize do
|
72
|
-
@future_value = value
|
73
|
-
end
|
74
|
-
end
|
75
70
|
end
|
76
71
|
end
|
data/lib/futuroscope/version.rb
CHANGED