ifuture 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -31
- data/ifuture.gemspec +3 -3
- data/lib/ifuture/version.rb +1 -1
- data/lib/ifuture.rb +19 -6
- data/test/helper.rb +1 -1
- data/test/ifuture_test.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60ffc81f189968c879d63579d39c587a12e87564
|
4
|
+
data.tar.gz: 56d0f225dc48bedef690a761242bb6ee5b091a90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aec4f8af199b38dd48d7ee6782f5f6a1597921f6ac398c527633a1d19e42cda93e206bc859285d5d4ec278ad8b4c7792061042f63aadb26de8658581748f7d9
|
7
|
+
data.tar.gz: 5bcf5518f45c538a93d4656e3078410e6904d435f7f3fe6523b94e1fa0741824bffcffc4a2781adc1c3e66d4d43ba1e385717ddbaa6af9796bd7a220cc443b1d
|
data/README.md
CHANGED
@@ -18,33 +18,17 @@ The Redis gem is required as well if you opt to use Redis instead of the default
|
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
require 'ifuture'
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
sleep 1
|
25
|
-
puts "#{n}..."
|
26
|
-
end
|
27
|
-
|
28
|
-
'Sekret!!'
|
21
|
+
future = IFuture.unix Marshal do
|
22
|
+
sleep 2
|
23
|
+
'Put that in your unix socket and smoke it'
|
29
24
|
end
|
30
25
|
|
31
|
-
future.ready?
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#=> 5
|
36
|
-
|
37
|
-
# 3...
|
38
|
-
# 2...
|
39
|
-
# 1...
|
40
|
-
# 0...
|
41
|
-
|
42
|
-
future.ready?
|
43
|
-
#=> true
|
44
|
-
|
45
|
-
future.value
|
46
|
-
#=> "Sekret!!"
|
26
|
+
future.ready? # => false
|
27
|
+
sleep 2
|
28
|
+
future.ready? # => true
|
29
|
+
future.value # => "Put that in your unix socket and smoke it"
|
47
30
|
```
|
31
|
+
|
48
32
|
### Code Serialization Format
|
49
33
|
|
50
34
|
The default serialization format is Marshal, but you can use JSON, YAML or other formats that implement the methods #load and #dump.
|
@@ -52,10 +36,9 @@ The default serialization format is Marshal, but you can use JSON, YAML or other
|
|
52
36
|
```ruby
|
53
37
|
require 'ifuture'
|
54
38
|
require 'json'
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
:human_readable
|
39
|
+
future = IFuture.unix JSON do
|
40
|
+
sleep 2
|
41
|
+
{ok: true}
|
59
42
|
end
|
60
43
|
```
|
61
44
|
|
@@ -65,11 +48,11 @@ By default iFuture uses IChannel with unix sockets for transferring serialized c
|
|
65
48
|
|
66
49
|
```ruby
|
67
50
|
require 'ifuture'
|
68
|
-
|
69
|
-
future = IFuture.new(Marshal, :redis, {host: 'localhost', key: 'readme'}) do
|
51
|
+
future = IFuture.redis Marshal, {host: 'localhost', key: 'readme'} do
|
70
52
|
sleep 5
|
71
|
-
|
53
|
+
42
|
72
54
|
end
|
55
|
+
future.value # => 42
|
73
56
|
```
|
74
57
|
|
75
58
|
## Contributing
|
data/ifuture.gemspec
CHANGED
@@ -8,16 +8,16 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = IFuture::VERSION
|
9
9
|
gem.authors = ['Shannon Skipper']
|
10
10
|
gem.email = ['shannonskipper@gmail.com']
|
11
|
-
gem.description = %q{
|
11
|
+
gem.description = %q{Process-based Futures for Ruby.}
|
12
12
|
gem.summary = %q{Futures implemented on top of IChannel for interprocess communication.}
|
13
13
|
gem.homepage = 'https://github.com/havenwood#readme'
|
14
14
|
gem.license = 'MIT'
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.require_paths = ['lib']
|
17
17
|
|
18
|
-
gem.add_development_dependency 'ichannel', '~>
|
18
|
+
gem.add_development_dependency 'ichannel', '~> 8.0.0'
|
19
19
|
gem.add_development_dependency 'minitest'
|
20
20
|
gem.add_development_dependency 'rake'
|
21
21
|
|
22
|
-
gem.add_runtime_dependency 'ichannel', '~>
|
22
|
+
gem.add_runtime_dependency 'ichannel', '~> 8.0.0'
|
23
23
|
end
|
data/lib/ifuture/version.rb
CHANGED
data/lib/ifuture.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
require 'ichannel'
|
2
|
-
|
2
|
+
require_relative 'ifuture/version'
|
3
3
|
|
4
4
|
class IFuture
|
5
|
-
def
|
6
|
-
|
7
|
-
|
5
|
+
def self.unix(serializer = Marshal, options = {}, &block)
|
6
|
+
allocate.tap do |obj|
|
7
|
+
obj.send :initialize, IChannel.unix(serializer, options), block
|
8
|
+
end
|
8
9
|
end
|
9
|
-
|
10
|
+
|
11
|
+
def self.redis(serializer = Marshal, options = {}, &block)
|
12
|
+
allocate.tap do |obj|
|
13
|
+
obj.send :initialize, IChannel.redis(serializer, options), block
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(channel, block)
|
18
|
+
@channel = channel
|
19
|
+
@pid = fork { @channel.put(block.call) }
|
20
|
+
end
|
21
|
+
private_class_method :new
|
22
|
+
|
10
23
|
def ready?
|
11
24
|
if defined? @value
|
12
25
|
true
|
@@ -19,7 +32,7 @@ class IFuture
|
|
19
32
|
if defined? @value
|
20
33
|
@value
|
21
34
|
else
|
22
|
-
@
|
35
|
+
Process.wait @pid
|
23
36
|
@value = @channel.get
|
24
37
|
end
|
25
38
|
end
|
data/test/helper.rb
CHANGED
data/test/ifuture_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ifuture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shannon Skipper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ichannel
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 8.0.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 8.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,15 +58,15 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 8.0.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description:
|
68
|
+
version: 8.0.0
|
69
|
+
description: Process-based Futures for Ruby.
|
70
70
|
email:
|
71
71
|
- shannonskipper@gmail.com
|
72
72
|
executables: []
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.0.
|
107
|
+
rubygems_version: 2.0.7
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Futures implemented on top of IChannel for interprocess communication.
|