contrails 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/contrails/chainable.rb +20 -4
- data/lib/contrails/parallel.rb +2 -3
- data/lib/contrails/process.rb +5 -23
- data/lib/contrails.rb +3 -0
- metadata +3 -3
data/Rakefile
CHANGED
@@ -38,7 +38,7 @@ spec = Gem::Specification.new do |s|
|
|
38
38
|
|
39
39
|
# Change these as appropriate
|
40
40
|
s.name = "contrails"
|
41
|
-
s.version = "0.
|
41
|
+
s.version = "0.2.0"
|
42
42
|
s.summary = "Declarative concurrency for EventMachine"
|
43
43
|
s.author = "Tim Cowlishaw"
|
44
44
|
s.email = "tim@timcowlishaw.co.uk"
|
data/lib/contrails/chainable.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
|
+
require 'em/deferrable'
|
2
|
+
autoload "Parallel", 'contrails/parallel'
|
3
|
+
autoload "Process", 'contrails/process'
|
1
4
|
module Contrails
|
2
5
|
module Chainable
|
3
6
|
|
7
|
+
module ClassMethods
|
8
|
+
def return(&b)
|
9
|
+
self.new(&b)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.included(base)
|
14
|
+
base.extend(ClassMethods)
|
15
|
+
base.send(:include, EventMachine::Deferrable)
|
16
|
+
end
|
17
|
+
|
4
18
|
def bind(other)
|
5
|
-
|
19
|
+
p = Process.new(&self)
|
20
|
+
p.callback(&other)
|
21
|
+
return p
|
6
22
|
end
|
7
23
|
|
8
24
|
def distribute(other)
|
9
|
-
|
25
|
+
Parallel.new(self, other)
|
10
26
|
end
|
11
27
|
|
12
28
|
def call(*a)
|
13
|
-
|
29
|
+
self.succeed(*run(*a))
|
14
30
|
end
|
15
31
|
|
16
32
|
def to_proc
|
@@ -24,7 +40,7 @@ module Contrails
|
|
24
40
|
def *(other)
|
25
41
|
self.distribute(other)
|
26
42
|
end
|
27
|
-
|
43
|
+
|
28
44
|
end
|
29
45
|
end
|
30
46
|
|
data/lib/contrails/parallel.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require 'em/deferrable'
|
2
|
-
require 'contrails/chainable'
|
3
1
|
require 'contrails/semaphore'
|
2
|
+
autoload "Chainable", 'contrails/chainable'
|
4
3
|
module Contrails
|
5
4
|
class Parallel
|
6
|
-
|
5
|
+
|
7
6
|
include Contrails::Chainable
|
8
7
|
def initialize(*procs)
|
9
8
|
results = []
|
data/lib/contrails/process.rb
CHANGED
@@ -1,32 +1,14 @@
|
|
1
|
-
|
2
|
-
require 'contrails/parallel'
|
1
|
+
autoload "Chainable", "contrails/chainable"
|
3
2
|
module Contrails
|
4
|
-
class Process
|
5
|
-
include
|
6
|
-
include Contrails::Chainable
|
7
|
-
|
8
|
-
class << self
|
9
|
-
def return(&b)
|
10
|
-
self.new(&b)
|
11
|
-
end
|
12
|
-
end
|
3
|
+
class Process
|
4
|
+
include Chainable
|
13
5
|
|
14
6
|
def initialize(&l)
|
15
7
|
@lambda = l
|
16
8
|
end
|
17
9
|
|
18
|
-
def
|
19
|
-
|
20
|
-
p.callback(&other)
|
21
|
-
return p
|
22
|
-
end
|
23
|
-
|
24
|
-
def distribute(other)
|
25
|
-
Contrails::Parallel.new(self, other)
|
26
|
-
end
|
27
|
-
|
28
|
-
def call(*a)
|
29
|
-
self.succeed(*@lambda.call(*a))
|
10
|
+
def run(*a)
|
11
|
+
@lambda.call(*a)
|
30
12
|
end
|
31
13
|
end
|
32
14
|
end
|
data/lib/contrails.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: contrails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tim Cowlishaw
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-22 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
hash: -
|
76
|
+
hash: -1600641507598680959
|
77
77
|
segments:
|
78
78
|
- 0
|
79
79
|
version: "0"
|