|
29 | 29 | { |
30 | 30 | "cell_type": "code", |
31 | 31 | "execution_count": null, |
32 | | - "metadata": {}, |
| 32 | + "metadata": { |
| 33 | + "collapsed": true |
| 34 | + }, |
33 | 35 | "outputs": [], |
34 | 36 | "source": [ |
35 | 37 | "Pkg.update()\n", |
|
46 | 48 | }, |
47 | 49 | { |
48 | 50 | "cell_type": "code", |
49 | | - "execution_count": 1, |
| 51 | + "execution_count": null, |
50 | 52 | "metadata": { |
51 | 53 | "collapsed": true |
52 | 54 | }, |
|
66 | 68 | }, |
67 | 69 | { |
68 | 70 | "cell_type": "code", |
69 | | - "execution_count": 2, |
70 | | - "metadata": {}, |
| 71 | + "execution_count": null, |
| 72 | + "metadata": { |
| 73 | + "collapsed": true |
| 74 | + }, |
71 | 75 | "outputs": [], |
72 | 76 | "source": [ |
73 | 77 | "const RUNS = 5\n", |
|
91 | 95 | }, |
92 | 96 | { |
93 | 97 | "cell_type": "code", |
94 | | - "execution_count": 3, |
| 98 | + "execution_count": null, |
95 | 99 | "metadata": {}, |
96 | | - "outputs": [ |
97 | | - { |
98 | | - "data": { |
99 | | - "text/plain": [ |
100 | | - "machine (generic function with 1 method)" |
101 | | - ] |
102 | | - }, |
103 | | - "execution_count": 3, |
104 | | - "metadata": {}, |
105 | | - "output_type": "execute_result" |
106 | | - } |
107 | | - ], |
| 100 | + "outputs": [], |
108 | 101 | "source": [ |
109 | | - "@resumable function machine(sim::Simulation, repair_facility::Resource, spares::Store{Coroutine})\n", |
| 102 | + "@resumable function machine(sim::Simulation, repair_facility::Resource, spares::Store{Process})\n", |
110 | 103 | " while true\n", |
111 | 104 | " try\n", |
112 | 105 | " @yield Timeout(sim, Inf)\n", |
|
141 | 134 | }, |
142 | 135 | { |
143 | 136 | "cell_type": "code", |
144 | | - "execution_count": 4, |
| 137 | + "execution_count": null, |
145 | 138 | "metadata": {}, |
146 | | - "outputs": [ |
147 | | - { |
148 | | - "data": { |
149 | | - "text/plain": [ |
150 | | - "start_sim (generic function with 1 method)" |
151 | | - ] |
152 | | - }, |
153 | | - "execution_count": 4, |
154 | | - "metadata": {}, |
155 | | - "output_type": "execute_result" |
156 | | - } |
157 | | - ], |
| 139 | + "outputs": [], |
158 | 140 | "source": [ |
159 | | - "@resumable function start_sim(sim::Simulation, repair_facility::Resource, spares::Store{Coroutine})\n", |
160 | | - " procs = Coroutine[]\n", |
| 141 | + "@resumable function start_sim(sim::Simulation, repair_facility::Resource, spares::Store{Process})\n", |
| 142 | + " procs = Process[]\n", |
161 | 143 | " for i=1:N\n", |
162 | | - " push!(procs, @coroutine machine(sim, repair_facility, spares))\n", |
| 144 | + " push!(procs, @process machine(sim, repair_facility, spares))\n", |
163 | 145 | " end\n", |
164 | 146 | " @yield Timeout(sim, 0.0)\n", |
165 | 147 | " for proc in procs\n", |
166 | 148 | " interrupt(proc)\n", |
167 | 149 | " end\n", |
168 | 150 | " for i=1:S\n", |
169 | | - " @yield Put(spares, @coroutine machine(sim, repair_facility, spares))\n", |
| 151 | + " @yield Put(spares, @process machine(sim, repair_facility, spares))\n", |
170 | 152 | " end\n", |
171 | 153 | "end" |
172 | 154 | ] |
|
180 | 162 | }, |
181 | 163 | { |
182 | 164 | "cell_type": "code", |
183 | | - "execution_count": 5, |
| 165 | + "execution_count": null, |
184 | 166 | "metadata": {}, |
185 | 167 | "outputs": [ |
186 | 168 | { |
|
198 | 180 | "function sim_repair()\n", |
199 | 181 | " sim = Simulation()\n", |
200 | 182 | " repair_facility = Resource(sim)\n", |
201 | | - " spares = Store{Coroutine}(sim)\n", |
202 | | - " @coroutine start_sim(sim, repair_facility, spares)\n", |
| 183 | + " spares = Store{Process}(sim)\n", |
| 184 | + " @process start_sim(sim, repair_facility, spares)\n", |
203 | 185 | " msg = run(sim)\n", |
204 | 186 | " stop_time = now(sim)\n", |
205 | 187 | " println(\"At time $stop_time: $msg\")\n", |
|
239 | 221 | "end\n", |
240 | 222 | "println(sum(results)/RUNS)" |
241 | 223 | ] |
242 | | - }, |
243 | | - { |
244 | | - "cell_type": "code", |
245 | | - "execution_count": null, |
246 | | - "metadata": { |
247 | | - "collapsed": true |
248 | | - }, |
249 | | - "outputs": [], |
250 | | - "source": [] |
251 | | - }, |
252 | | - { |
253 | | - "cell_type": "code", |
254 | | - "execution_count": null, |
255 | | - "metadata": { |
256 | | - "collapsed": true |
257 | | - }, |
258 | | - "outputs": [], |
259 | | - "source": [] |
260 | 224 | } |
261 | 225 | ], |
262 | 226 | "metadata": { |
|
0 commit comments