You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/guides/basics.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ using ResumableFunctions
21
21
using SimJulia
22
22
23
23
@resumable function example(env::Environment)
24
-
event = Timeout(env, 1, value=42)
24
+
event = timeout(env, 1, value=42)
25
25
value = @yield event
26
26
println("now=", now(env), ", value=", value)
27
27
end
@@ -35,11 +35,11 @@ run(sim)
35
35
now=1.0, value=42
36
36
```
37
37
38
-
The `example` process function above first creates a `Timeout` event. It passes the environment, a delay, and a value to it. The `Timeout` schedules itself at `now + delay` (that’s why the environment is required); other event types usually schedule themselves at the current simulation time.
38
+
The `example` process function above first creates a `timeout` event. It passes the environment, a delay, and a value to it. The `timeout` schedules itself at `now + delay` (that’s why the environment is required); other event types usually schedule themselves at the current simulation time.
39
39
40
-
The process function then yields the event and thus gets suspended. It is resumed, when SimJulia processes the `Timeout` event. The process function also receives the event’s value (42) – this is, however, optional, so `@yield event` would have been okay if the you were not interested in the value or if the event had no value at all.
40
+
The process function then yields the event and thus gets suspended. It is resumed, when SimJulia processes the `timeout` event. The process function also receives the event’s value (42) – this is, however, optional, so `@yield event` would have been okay if the you were not interested in the value or if the event had no value at all.
41
41
42
-
Finally, the process function prints the current simulation time (that is accessible via the `now` function) and the `Timeout`’s value.
42
+
Finally, the process function prints the current simulation time (that is accessible via the `now` function) and the `timeout`’s value.
43
43
44
44
If all required process functions are defined, you can instantiate all objects for your simulation. In most cases, you start by creating an instance of `Environment`, e.g. a `Simulation`, because you’ll need to pass it around a lot when creating everything else.
Copy file name to clipboardExpand all lines: docs/src/guides/environments.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ end
30
30
31
31
- Instead of passing a number as second argument to `run`, you can also pass any event to it. `run` will then return when the event has been processed.
32
32
33
-
Assuming that the current time is 0, `run(env, Timeout(env, 5))` is equivalent to `run(env, 5)`.
33
+
Assuming that the current time is 0, `run(env, timeout(env, 5))` is equivalent to `run(env, 5)`.
34
34
35
35
You can also pass other types of events (remember, that a `Process` is an event, too):
36
36
@@ -39,7 +39,7 @@ using ResumableFunctions
39
39
using SimJulia
40
40
41
41
@resumable function my_process(env::Environment)
42
-
@yield Timeout(env, 1)
42
+
@yield timeout(env, 1)
43
43
"Monty Python's Flying Circus"
44
44
end
45
45
@@ -63,14 +63,14 @@ end
63
63
64
64
## State access
65
65
66
-
The environment allows you to get the current simulation time via the function `now`. The simulation time is a number without unit and is increased via `Timeout` events.
66
+
The environment allows you to get the current simulation time via the function `now`. The simulation time is a number without unit and is increased via `timeout` events.
67
67
68
68
By default, the simulation starts at time 0, but you can pass an `initial_time` to the `Simulation` constructor to use something else.
69
69
70
70
Note
71
71
72
72
!!! note
73
-
Although the simulation time is technically unitless, you can pretend that it is, for example, in milliseconds and use it like a timestamp returned by `Base.Dates.datetime2epochm` to calculate a date or the day of the week. The `Simulation` constructor and the `run` function accept as argument a `Base.Dates.DateTime` and the `Timeout` constructor a `Base.Dates.Delay`. Together with the convenience function `nowDateTime` a simulation can transparantly schedule its events in seconds, minutes, hours, days, ...
73
+
Although the simulation time is technically unitless, you can pretend that it is, for example, in milliseconds and use it like a timestamp returned by `Base.Dates.datetime2epochm` to calculate a date or the day of the week. The `Simulation` constructor and the `run` function accept as argument a `Base.Dates.DateTime` and the `timeout` constructor a `Base.Dates.Delay`. Together with the convenience function `nowDateTime` a simulation can transparantly schedule its events in seconds, minutes, hours, days, ...
74
74
75
75
The function `active_process` is comparable to `Base.Libc.getpid` and returns the current active `Process`. If no process is active, a `NullException` is thrown. A process is active when its process function is being executed. It becomes inactive (or suspended) when it yields an event.
76
76
@@ -90,7 +90,7 @@ julia> @resumable function my_proc(env::Environment)
90
90
while true
91
91
println(active_process(env))
92
92
subfunc(env)
93
-
@yield Timeout(env, 1)
93
+
@yield timeout(env, 1)
94
94
end
95
95
end
96
96
my_proc (generic function with 1 method)
@@ -122,7 +122,7 @@ A generator function can have a return value:
Copy file name to clipboardExpand all lines: docs/src/guides/events.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
SimJulia includes an extensive set of event types for various purposes. All of them are descendants of `AbstractEvent`. Here the following events are discussed:
4
4
5
5
-`Event`
6
-
-`Timeout`
6
+
-`timeout`
7
7
-`Operator`
8
8
9
9
The guide to resources describes the various resource events.
0 commit comments