dramatis 0.0.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.
Files changed (120) hide show
  1. data/History.txt +7 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +119 -0
  4. data/README.txt +57 -0
  5. data/Rakefile +4 -0
  6. data/config/hoe.rb +70 -0
  7. data/config/requirements.rb +17 -0
  8. data/examples/README.txt +20 -0
  9. data/examples/auction.rb +90 -0
  10. data/examples/bank/bank.rb +7 -0
  11. data/examples/bank/bank_test.rb +7 -0
  12. data/examples/exception.rb +40 -0
  13. data/examples/fib/conservative.rb +50 -0
  14. data/examples/fib/future.rb +5 -0
  15. data/examples/fib/original.rb +33 -0
  16. data/examples/fib/threads.rb +51 -0
  17. data/examples/im/distributed/chat/client.rb +49 -0
  18. data/examples/im/distributed/chat/screen/fox.rb +92 -0
  19. data/examples/im/distributed/chat/screen.rb +11 -0
  20. data/examples/im/distributed/chat/server.rb +72 -0
  21. data/examples/im/distributed/chat.rb +5 -0
  22. data/examples/im/distributed/client.rb +9 -0
  23. data/examples/im/distributed/run.rb +18 -0
  24. data/examples/im/distributed/server.rb +11 -0
  25. data/examples/im/single/chat/client.rb +50 -0
  26. data/examples/im/single/chat/screen/fox.rb +96 -0
  27. data/examples/im/single/chat/screen/wxs.rb +63 -0
  28. data/examples/im/single/chat/screen.rb +11 -0
  29. data/examples/im/single/chat/server.rb +72 -0
  30. data/examples/im/single/chat.rb +5 -0
  31. data/examples/im/single/fox.rb +18 -0
  32. data/examples/im/single/wxchat.rb +19 -0
  33. data/examples/pingpong/actor.rb +33 -0
  34. data/examples/pingpong/actor_rec.rb +34 -0
  35. data/examples/pingpong/pingpong.txt +315 -0
  36. data/examples/pingpong/scala.rb +41 -0
  37. data/examples/pingpong/serial.rb +26 -0
  38. data/examples/pretty.txt +108 -0
  39. data/examples/telephone/.irbrc +2 -0
  40. data/examples/telephone/3esl.txt +21877 -0
  41. data/examples/telephone/fifth/kid.rb +36 -0
  42. data/examples/telephone/fifth/run.rb +26 -0
  43. data/examples/telephone/first/kid.rb +31 -0
  44. data/examples/telephone/first/run.rb +20 -0
  45. data/examples/telephone/fourth/kid.rb +31 -0
  46. data/examples/telephone/fourth/run.rb +26 -0
  47. data/examples/telephone/mangler.rb +53 -0
  48. data/examples/telephone/second/kid.rb +26 -0
  49. data/examples/telephone/second/run.rb +20 -0
  50. data/examples/telephone/seventh/kid.rb +40 -0
  51. data/examples/telephone/seventh/run.rb +35 -0
  52. data/examples/telephone/seventh/test.rb +28 -0
  53. data/examples/telephone/seventh/test2.rb +10 -0
  54. data/examples/telephone/sixth/kid.rb +39 -0
  55. data/examples/telephone/sixth/run.rb +26 -0
  56. data/examples/telephone/third/kid.rb +31 -0
  57. data/examples/telephone/third/run.rb +21 -0
  58. data/lib/dramatis/actor/interface.rb +118 -0
  59. data/lib/dramatis/actor/name/interface.rb +128 -0
  60. data/lib/dramatis/actor/name.rb +44 -0
  61. data/lib/dramatis/actor.rb +96 -0
  62. data/lib/dramatis/deadlock.rb +123 -0
  63. data/lib/dramatis/error/uncaught.rb +19 -0
  64. data/lib/dramatis/error.rb +125 -0
  65. data/lib/dramatis/future/interface.rb +45 -0
  66. data/lib/dramatis/future.rb +32 -0
  67. data/lib/dramatis/runtime/actor/main.rb +3 -0
  68. data/lib/dramatis/runtime/actor.rb +294 -0
  69. data/lib/dramatis/runtime/gate.rb +244 -0
  70. data/lib/dramatis/runtime/scheduler.rb +374 -0
  71. data/lib/dramatis/runtime/task.rb +390 -0
  72. data/lib/dramatis/runtime/thread_pool.rb +149 -0
  73. data/lib/dramatis/runtime/timer.rb +5 -0
  74. data/lib/dramatis/runtime.rb +129 -0
  75. data/lib/dramatis/shoes/runtime.rb +7 -0
  76. data/lib/dramatis/shoes.rb +14 -0
  77. data/lib/dramatis/version.rb +8 -0
  78. data/lib/dramatis.rb +73 -0
  79. data/log/debug.log +0 -0
  80. data/script/destroy +14 -0
  81. data/script/generate +14 -0
  82. data/script/txt2html +74 -0
  83. data/setup.rb +1585 -0
  84. data/spec/dramatis/actor/become_spec.rb +17 -0
  85. data/spec/dramatis/actor/future_spec.rb +189 -0
  86. data/spec/dramatis/actor/name_spec.rb +141 -0
  87. data/spec/dramatis/actor/task_spec.rb +75 -0
  88. data/spec/dramatis/actor_spec.rb +492 -0
  89. data/spec/dramatis/dramatis_spec.rb +23 -0
  90. data/spec/dramatis/exc_spec.rb +78 -0
  91. data/spec/dramatis/runtime/gate_spec.rb +57 -0
  92. data/spec/dramatis/runtime/thread_pool.rb +30 -0
  93. data/spec/dramatis/shoes_spec.rb +11 -0
  94. data/spec/dramatis/simple_spec.rb +32 -0
  95. data/spec/exp_spec.rb +21 -0
  96. data/spec/simple2_spec.rb +36 -0
  97. data/spec/simple_spec.rb +30 -0
  98. data/spec/spec.opts +0 -0
  99. data/spec/spec_helper.rb +26 -0
  100. data/spec/thread_spec.rb +13 -0
  101. data/tasks/deployment.rake +34 -0
  102. data/tasks/environment.rake +7 -0
  103. data/tasks/rspec.rake +21 -0
  104. data/tasks/website.rake +17 -0
  105. data/test/jruby_lm.rb +13 -0
  106. data/test/test.rb +19 -0
  107. data/test/test10.rb +43 -0
  108. data/test/test11.rb +45 -0
  109. data/test/test12.rb +60 -0
  110. data/test/test13.rb +71 -0
  111. data/test/test2.rb +12 -0
  112. data/test/test3.rb +10 -0
  113. data/test/test4.rb +29 -0
  114. data/test/test5.rb +8 -0
  115. data/test/test6.rb +32 -0
  116. data/test/test7.rb +48 -0
  117. data/test/test8.rb +133 -0
  118. data/test/test9.rb +105 -0
  119. data/test/test_exc.rb +22 -0
  120. metadata +180 -0
data/test/test8.rb ADDED
@@ -0,0 +1,133 @@
1
+ #!/bin/env ruby
2
+
3
+ $:.push File.join( File.dirname(__FILE__), "..", "lib" )
4
+
5
+ require 'dramatis/actor/name'
6
+ require 'dramatis/runtime'
7
+
8
+ require 'pp'
9
+
10
+ include Dramatis
11
+
12
+ # no call threading case
13
+
14
+ # This test is trying to recover from deadlock ... which is a little iffy. Seems to work but not
15
+ # recommended.
16
+
17
+ # Deadlock recovery needs to be beefed up.
18
+
19
+ a = Class.new do
20
+
21
+ include Dramatis::Actor
22
+
23
+ def initialize
24
+ actor.refuse :fromB
25
+ end
26
+
27
+ def allow
28
+ # p "allow delivered"
29
+ actor.default :fromB
30
+
31
+ # just for the hell of it,
32
+ # def fromB here; if called earlier
33
+ # should fail making timing errors
34
+ # more obvious
35
+
36
+ class << self
37
+ def fromB
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ b = Class.new do
46
+
47
+ include Dramatis::Actor
48
+
49
+ def initialize anA
50
+ @anA = anA
51
+ @count = 0
52
+ actor.always :count, true
53
+ end
54
+
55
+ def startB
56
+ # p ">> startB"
57
+ @anA.fromB
58
+ # p "<< startB"
59
+ end
60
+
61
+ def count
62
+ # p ">count< #{@count}"
63
+ @count
64
+ end
65
+
66
+ def increment
67
+ # p ">increment<"
68
+ @count += 1
69
+ end
70
+
71
+ def shouldDeadlock
72
+ end
73
+
74
+ end
75
+
76
+ anA = a.new
77
+ aB = b.new anA
78
+
79
+ aB_cast = interface( aB ).continue nil
80
+
81
+ c = aB.count
82
+
83
+ raise "hell #{c}" if c != 0
84
+
85
+ aB.increment
86
+
87
+ raise "hell" if aB.count != 1
88
+
89
+ aB_cast.increment
90
+
91
+ Dramatis::Runtime.current.warnings = false
92
+
93
+ Dramatis::Runtime.current.quiesce
94
+
95
+ raise "hell" if aB.count != 2
96
+
97
+ aB_cast.startB
98
+ aB_cast.increment
99
+
100
+ Dramatis::Runtime.current.quiesce
101
+
102
+ raise "hell" if aB.count != 2
103
+ raise "hell" if Dramatis::Runtime.current.exceptions.length != 0
104
+
105
+ begin
106
+ aB.shouldDeadlock
107
+ raise "this should raise a deadlock since aB should be waiting on the fromB rpc"
108
+ rescue Dramatis::Deadlock => deadlock
109
+ begin
110
+ Dramatis::Runtime.current.quiesce
111
+ rescue Dramatis::Deadlock
112
+ rescue Dramatis::Error::Uncaught
113
+ end
114
+ raise "hell #{Dramatis::Runtime.current.exceptions.length}" if Dramatis::Runtime.current.exceptions.length != 2
115
+ Dramatis::Runtime.current.clear_exceptions
116
+ raise "hell" if Dramatis::Runtime.current.exceptions.length != 0
117
+ end
118
+
119
+ raise "hell" if aB.count != 2
120
+
121
+ # p "b4 allow"
122
+ anA.allow
123
+ # p "a4 allow"
124
+
125
+ # should get through fine now
126
+
127
+ aB_cast.startB
128
+ aB_cast.increment
129
+
130
+ Dramatis::Runtime.current.quiesce
131
+
132
+ raise "hell" if aB.count != 3
133
+
data/test/test9.rb ADDED
@@ -0,0 +1,105 @@
1
+ #!/bin/env ruby
2
+
3
+ $:.push File.join( File.dirname(__FILE__), "..", "lib" )
4
+
5
+ require 'dramatis/actor/name'
6
+ require 'dramatis/runtime'
7
+
8
+ require 'pp'
9
+
10
+ include Dramatis
11
+
12
+ # no call threading case
13
+
14
+ a = Class.new do
15
+
16
+ include Dramatis::Actor
17
+
18
+ def initialize
19
+ actor.refuse :fromB
20
+ end
21
+
22
+ def allow
23
+ # p "allow delivered"
24
+ actor.default :fromB
25
+
26
+ # just for the hell of it,
27
+ # def fromB here; if called earlier
28
+ # should fail making timing errors
29
+ # more obvious
30
+
31
+ class << self
32
+ def fromB
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ b = Class.new do
41
+
42
+ include Dramatis::Actor
43
+
44
+ def initialize anA
45
+ @anA = anA
46
+ @count = 0
47
+ actor.always :count, true
48
+ end
49
+
50
+ def startB
51
+ # p ">> startB"
52
+ @anA.fromB
53
+ # p "<< startB"
54
+ end
55
+
56
+ def count
57
+ # p ">count< #{@count}"
58
+ @count
59
+ end
60
+
61
+ def increment
62
+ # p ">increment<"
63
+ @count += 1
64
+ end
65
+
66
+ def shouldDeadlock
67
+ end
68
+
69
+ end
70
+
71
+ anA = a.new
72
+ aB = b.new anA
73
+
74
+ aB_cast = interface( aB ).continue nil
75
+
76
+ c = aB.count
77
+
78
+ raise "hell #{c}" if c != 0
79
+
80
+ aB.increment
81
+
82
+ raise "hell" if aB.count != 1
83
+
84
+ aB_cast.increment
85
+
86
+ Dramatis::Runtime.current.quiesce
87
+
88
+ raise "hell" if aB.count != 2
89
+
90
+ aB_cast.startB
91
+ aB_cast.increment
92
+
93
+ Dramatis::Runtime.current.quiesce
94
+
95
+ raise "hell" if aB.count != 2
96
+
97
+ # p "b4 allow"
98
+ anA.allow
99
+ # p "a4 allow"
100
+
101
+ Dramatis::Runtime.current.quiesce
102
+
103
+ # p "c4"
104
+ raise "hell" if aB.count != 3
105
+ # p "d4"
data/test/test_exc.rb ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ raise Exception.new( "hell" )
5
+ rescue Exception => e
6
+ p e
7
+ p e.backtrace
8
+ end
9
+
10
+ begin
11
+ begin
12
+ raise Exception.new( "hell" )
13
+ rescue Exception => e
14
+ p e
15
+ p e.backtrace
16
+ raise e
17
+ end
18
+ rescue Exception => e
19
+ p e
20
+ p e.backtrace
21
+ end
22
+
metadata ADDED
@@ -0,0 +1,180 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dramatis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Steven Parkes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-05 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: an Actor library for Ruby and Python
17
+ email:
18
+ - smparkes@smparkes.net
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - History.txt
25
+ - License.txt
26
+ - Manifest.txt
27
+ - README.txt
28
+ - examples/README.txt
29
+ - examples/pingpong/pingpong.txt
30
+ - examples/pretty.txt
31
+ - examples/telephone/3esl.txt
32
+ files:
33
+ - History.txt
34
+ - License.txt
35
+ - Manifest.txt
36
+ - README.txt
37
+ - Rakefile
38
+ - config/hoe.rb
39
+ - config/requirements.rb
40
+ - examples/README.txt
41
+ - examples/auction.rb
42
+ - examples/bank/bank.rb
43
+ - examples/bank/bank_test.rb
44
+ - examples/exception.rb
45
+ - examples/fib/conservative.rb
46
+ - examples/fib/future.rb
47
+ - examples/fib/original.rb
48
+ - examples/fib/threads.rb
49
+ - examples/im/distributed/chat.rb
50
+ - examples/im/distributed/chat/client.rb
51
+ - examples/im/distributed/chat/screen.rb
52
+ - examples/im/distributed/chat/screen/fox.rb
53
+ - examples/im/distributed/chat/server.rb
54
+ - examples/im/distributed/client.rb
55
+ - examples/im/distributed/run.rb
56
+ - examples/im/distributed/server.rb
57
+ - examples/im/single/chat.rb
58
+ - examples/im/single/chat/client.rb
59
+ - examples/im/single/chat/screen.rb
60
+ - examples/im/single/chat/screen/fox.rb
61
+ - examples/im/single/chat/screen/wxs.rb
62
+ - examples/im/single/chat/server.rb
63
+ - examples/im/single/fox.rb
64
+ - examples/im/single/wxchat.rb
65
+ - examples/pingpong/actor.rb
66
+ - examples/pingpong/actor_rec.rb
67
+ - examples/pingpong/pingpong.txt
68
+ - examples/pingpong/scala.rb
69
+ - examples/pingpong/serial.rb
70
+ - examples/pretty.txt
71
+ - examples/telephone/.irbrc
72
+ - examples/telephone/3esl.txt
73
+ - examples/telephone/fifth/kid.rb
74
+ - examples/telephone/fifth/run.rb
75
+ - examples/telephone/first/kid.rb
76
+ - examples/telephone/first/run.rb
77
+ - examples/telephone/fourth/kid.rb
78
+ - examples/telephone/fourth/run.rb
79
+ - examples/telephone/mangler.rb
80
+ - examples/telephone/second/kid.rb
81
+ - examples/telephone/second/run.rb
82
+ - examples/telephone/seventh/kid.rb
83
+ - examples/telephone/seventh/run.rb
84
+ - examples/telephone/seventh/test.rb
85
+ - examples/telephone/seventh/test2.rb
86
+ - examples/telephone/sixth/kid.rb
87
+ - examples/telephone/sixth/run.rb
88
+ - examples/telephone/third/kid.rb
89
+ - examples/telephone/third/run.rb
90
+ - lib/dramatis.rb
91
+ - lib/dramatis/actor.rb
92
+ - lib/dramatis/actor/interface.rb
93
+ - lib/dramatis/actor/name.rb
94
+ - lib/dramatis/actor/name/interface.rb
95
+ - lib/dramatis/deadlock.rb
96
+ - lib/dramatis/error.rb
97
+ - lib/dramatis/error/uncaught.rb
98
+ - lib/dramatis/future.rb
99
+ - lib/dramatis/future/interface.rb
100
+ - lib/dramatis/runtime.rb
101
+ - lib/dramatis/runtime/actor.rb
102
+ - lib/dramatis/runtime/actor/main.rb
103
+ - lib/dramatis/runtime/gate.rb
104
+ - lib/dramatis/runtime/scheduler.rb
105
+ - lib/dramatis/runtime/task.rb
106
+ - lib/dramatis/runtime/thread_pool.rb
107
+ - lib/dramatis/runtime/timer.rb
108
+ - lib/dramatis/shoes.rb
109
+ - lib/dramatis/shoes/runtime.rb
110
+ - lib/dramatis/version.rb
111
+ - log/debug.log
112
+ - script/destroy
113
+ - script/generate
114
+ - script/txt2html
115
+ - setup.rb
116
+ - spec/dramatis/actor/become_spec.rb
117
+ - spec/dramatis/actor/future_spec.rb
118
+ - spec/dramatis/actor/name_spec.rb
119
+ - spec/dramatis/actor/task_spec.rb
120
+ - spec/dramatis/actor_spec.rb
121
+ - spec/dramatis/dramatis_spec.rb
122
+ - spec/dramatis/exc_spec.rb
123
+ - spec/dramatis/runtime/gate_spec.rb
124
+ - spec/dramatis/runtime/thread_pool.rb
125
+ - spec/dramatis/shoes_spec.rb
126
+ - spec/dramatis/simple_spec.rb
127
+ - spec/exp_spec.rb
128
+ - spec/simple2_spec.rb
129
+ - spec/simple_spec.rb
130
+ - spec/spec.opts
131
+ - spec/spec_helper.rb
132
+ - spec/thread_spec.rb
133
+ - tasks/deployment.rake
134
+ - tasks/environment.rake
135
+ - tasks/rspec.rake
136
+ - tasks/website.rake
137
+ - test/jruby_lm.rb
138
+ - test/test.rb
139
+ - test/test10.rb
140
+ - test/test11.rb
141
+ - test/test12.rb
142
+ - test/test13.rb
143
+ - test/test2.rb
144
+ - test/test3.rb
145
+ - test/test4.rb
146
+ - test/test5.rb
147
+ - test/test6.rb
148
+ - test/test7.rb
149
+ - test/test8.rb
150
+ - test/test9.rb
151
+ - test/test_exc.rb
152
+ has_rdoc: true
153
+ homepage: http://dramatis.rubyforge.org
154
+ post_install_message:
155
+ rdoc_options:
156
+ - --main
157
+ - README.txt
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: "0"
165
+ version:
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: "0"
171
+ version:
172
+ requirements: []
173
+
174
+ rubyforge_project: dramatis
175
+ rubygems_version: 1.1.1
176
+ signing_key:
177
+ specification_version: 2
178
+ summary: an Actor library for Ruby and Python
179
+ test_files:
180
+ - test/test_exc.rb