11using SimJulia
22
3- @stateful function client (sim:: Simulation , res:: Resource , i:: Int , priority:: Int )
3+ @resumable function client (sim:: Simulation , res:: Resource , i:: Int , priority:: Int )
44 println (" $(now (sim)) , client $i is waiting" )
55 @yield return Request (res, priority= priority)
66 println (" $(now (sim)) , client $i is being served" )
@@ -9,7 +9,7 @@ using SimJulia
99 @yield return Release (res)
1010end
1111
12- @stateful function generate (sim:: Simulation , res:: Resource )
12+ @resumable function generate (sim:: Simulation , res:: Resource )
1313 i = 1
1414 while true
1515 @coroutine client (sim, res, i, 10 - i)
@@ -24,7 +24,7 @@ res = Resource(sim, 2; level=1)
2424@coroutine generate (sim, res)
2525run (sim)
2626
27- @stateful function my_consumer (sim:: Simulation , con:: Container )
27+ @resumable function my_consumer (sim:: Simulation , con:: Container )
2828 i = 1
2929 while true
3030 amount = 3 * rand ()
@@ -45,7 +45,7 @@ run(sim)
4545 end
4646end
4747
48- @stateful function my_producer (sim:: Simulation , con:: Container )
48+ @resumable function my_producer (sim:: Simulation , con:: Container )
4949 i = 1
5050 while true
5151 amount = 2 * rand ()
@@ -66,7 +66,7 @@ con = Container(sim, 10.0; level=5.0)
6666@coroutine my_producer (sim, con)
6767run (sim)
6868
69- @stateful function resource_user (sim:: Simulation , res:: Resource , i:: Int )
69+ @resumable function resource_user (sim:: Simulation , res:: Resource , i:: Int )
7070 @request res req begin
7171 println (" Requested $i " )
7272 val = @yield return req | Timeout (sim, rand ())
@@ -80,7 +80,7 @@ run(sim)
8080 println (" Released automatically $i " )
8181end
8282
83- @stateful function create_users (sim:: Simulation )
83+ @resumable function create_users (sim:: Simulation )
8484 res = Resource (sim)
8585 i = 1
8686 while true
0 commit comments