futuroscope 0.1.0 → 0.1.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/futuroscope/future.rb +3 -11
- 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: 9a38124bea1c0800d134fa4600b8e5687556a8ed
|
4
|
+
data.tar.gz: 02e07ba6a3f537c994dee4301082e095b1c881cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e3aa4fd153a337930353629fee374f6213e9890a9769af41a05bb58403266596f4fc7f4d1b06848ea846058beb6dc1876f834abc12947da026dc2e0209b791e
|
7
|
+
data.tar.gz: 038a7fb36f090ae38b36cad22d46f810a85428b293e1156f6f201f21a289f30bbe36ec190f5180291087f7f9b0453f3f842550215cfbb2c8d7705923d9259e6e
|
data/lib/futuroscope/future.rb
CHANGED
@@ -6,7 +6,7 @@ module Futuroscope
|
|
6
6
|
# the future. That is, will block when the result is not ready until it is,
|
7
7
|
# and will return it instantly if the thread's execution already finished.
|
8
8
|
#
|
9
|
-
class Future <
|
9
|
+
class Future < Delegator
|
10
10
|
extend ::Forwardable
|
11
11
|
|
12
12
|
# Initializes a future with a block and starts its execution.
|
@@ -42,27 +42,19 @@ module Futuroscope
|
|
42
42
|
# completed or return its value otherwise. Can be called multiple times.
|
43
43
|
#
|
44
44
|
# Returns the Future's block execution result.
|
45
|
-
def
|
45
|
+
def __getobj__
|
46
46
|
resolved = resolved_future_value
|
47
47
|
|
48
48
|
raise resolved[:exception] if resolved[:exception]
|
49
49
|
resolved[:value]
|
50
50
|
end
|
51
51
|
|
52
|
-
def_delegators :
|
52
|
+
def_delegators :__getobj__, :class, :kind_of?, :is_a?, :clone
|
53
53
|
|
54
54
|
private
|
55
55
|
|
56
56
|
def resolved_future_value
|
57
57
|
@resolved_future ||= @queue.pop
|
58
58
|
end
|
59
|
-
|
60
|
-
def method_missing(method, *args)
|
61
|
-
future_value.send(method, *args)
|
62
|
-
end
|
63
|
-
|
64
|
-
def respond_to_missing?(method, include_private = false)
|
65
|
-
future_value.respond_to?(method, include_private)
|
66
|
-
end
|
67
59
|
end
|
68
60
|
end
|
data/lib/futuroscope/version.rb
CHANGED