em-scenario 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -70,6 +70,41 @@ EM.run do
70
70
  end
71
71
  ```
72
72
 
73
+ ### Mixing multis and sequences
74
+
75
+ `Multi` and `Sequence` handle any deferrable objects and are deferrable too. You can compound story :
76
+
77
+ ```
78
+ /-#-\ /-#-#--\
79
+ -#---#---#----#-----#-
80
+ \-#-/ \----#-/
81
+
82
+ ```
83
+
84
+ ```ruby
85
+ EM.run do
86
+ stack = []
87
+ EM::Scenario::Sequence.new do
88
+ m = EM::Scenario::Multi.new
89
+ 10.times do
90
+ m.add(rand_timer(0.5) { stack << 0 })
91
+ end
92
+ m
93
+ end.then do
94
+ m = EM::Scenario::Multi.new
95
+ 10.times do
96
+ m.add(rand_timer(0.5) { stack << 1 })
97
+ end
98
+ m
99
+ end.then do
100
+ rand_timer(0.5) do
101
+ assert [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] == stack
102
+ EM.stop
103
+ end
104
+ end
105
+ end
106
+ ```
107
+
73
108
  Experimentations
74
109
  ----------------
75
110
 
@@ -17,6 +17,7 @@ module EventMachine
17
17
  @actions -= 1
18
18
  self.succeed if @actions == 0
19
19
  end
20
+ self
20
21
  end
21
22
 
22
23
  end
@@ -22,9 +22,9 @@ module EventMachine
22
22
  @action << proc {
23
23
  defer = block.call(@bag, *@bag[size+1])
24
24
  if size < @action.length
25
- defer.callback do
26
- @action[size].call
27
- end
25
+ defer.callback { @action[size].call }
26
+ else
27
+ self.succeed
28
28
  end
29
29
  }
30
30
  self
@@ -0,0 +1,22 @@
1
+ require "eventmachine"
2
+
3
+ module EventMachine
4
+ module Scenario
5
+
6
+ class While
7
+ include EM::Deferrable
8
+
9
+ def initialize &block
10
+ @criteria = block
11
+ @queue = EM::Queue.new
12
+ self
13
+ end
14
+
15
+ def do
16
+
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-scenario
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-21 00:00:00.000000000 Z
12
+ date: 2011-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &2152036200 !ruby/object:Gem::Requirement
16
+ requirement: &2164392440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.0.beta3
21
+ version: 1.0.0.beta.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152036200
24
+ version_requirements: *2164392440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &2160363040 !ruby/object:Gem::Requirement
27
+ requirement: &2164391960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2160363040
35
+ version_requirements: *2164391960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2160375720 !ruby/object:Gem::Requirement
38
+ requirement: &2164391580 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2160375720
46
+ version_requirements: *2164391580
47
47
  description: Handling simpler story with event machine's callback
48
48
  email: mathieu@garambrogne.net
49
49
  executables: []
@@ -59,6 +59,7 @@ files:
59
59
  - lib/scenario/multi.rb
60
60
  - lib/scenario/sequence.rb
61
61
  - lib/scenario/timer.rb
62
+ - lib/scenario/while.rb
62
63
  - lib/scenario.rb
63
64
  homepage: http://github.com/athoune/em-scenario
64
65
  licenses: []