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
An exemplary use case for this is the resource system: If a process function calls `request` to request a `Resource`, the resource determines the requesting process via `active_process`.
115
+
An exemplary use case for this is the resource system: If a process function calls `lock` to request a `Resource`, the resource determines the requesting process via `active_process`.
Copy file name to clipboardExpand all lines: docs/src/tutorial.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
@@ -291,7 +291,7 @@ In this section, we’ll briefly introduce ConcurrentSim’s `Resource` class.
291
291
292
292
We’ll slightly modify our electric vehicle process `car` that we introduced in the last sections.
293
293
294
-
The car will now drive to a battery charging station (BCS) and request one of its two charging spots. If both of these spots are currently in use, it waits until one of them becomes available again. It then starts charging its battery and leaves the station afterwards:
294
+
The car will now drive to a battery charging station (BCS) and request (lock) one of its two charging spots. If both of these spots are currently in use, it waits until one of them becomes available again. It then starts charging its battery and leaves the station afterwards:
295
295
296
296
```jldoctest
297
297
julia> using ResumableFunctions
@@ -301,7 +301,7 @@ julia> using ConcurrentSim
301
301
julia> @resumable function car(env::Environment, name::Int, bcs::Resource, driving_time::Number, charge_duration::Number)
302
302
@yield timeout(sim, driving_time)
303
303
println(name, " arriving at ", now(env))
304
-
@yield request(bcs)
304
+
@yield lock(bcs)
305
305
println(name, " starting to charge at ", now(env))
The resource’s `request` function generates an event that lets you wait until the resource becomes available again. If you are resumed, you “own” the resource until you release it.
313
+
The resource’s `lock` function generates an event that lets you wait until the resource becomes available again. If you are resumed, you “own” the resource until you release it.
314
314
315
315
You are responsible to call `release` once you are done using the resource. When you release a resource, the next waiting process is resumed and now “owns” one of the resource’s slots. The basic `Resource` sorts waiting processes in a FIFO (first in—first out) way.
316
316
@@ -324,7 +324,7 @@ DocTestSetup = quote
324
324
@resumable function car(env::Environment, name::Int, bcs::Resource, driving_time::Number, charge_duration::Number)
325
325
@yield timeout(sim, driving_time)
326
326
println(name, " arriving at ", now(env))
327
-
@yield request(bcs)
327
+
@yield lock(bcs)
328
328
println(name, " starting to charge at ", now(env))
329
329
@yield timeout(sim, charge_duration)
330
330
println(name, " leaving the bcs at ", now(env))
@@ -351,7 +351,7 @@ DocTestSetup = quote
351
351
@resumable function car(env::Environment, name::Int, bcs::Resource, driving_time::Number, charge_duration::Number)
352
352
@yield timeout(sim, driving_time)
353
353
println(name, " arriving at ", now(env))
354
-
@yield request(bcs)
354
+
@yield lock(bcs)
355
355
println(name, " starting to charge at ", now(env))
356
356
@yield timeout(sim, charge_duration)
357
357
println(name, " leaving the bcs at ", now(env))
@@ -393,7 +393,7 @@ DocTestSetup = quote
393
393
@resumable function car(env::Environment, name::Int, bcs::Resource, driving_time::Number, charge_duration::Number)
394
394
@yield timeout(sim, driving_time)
395
395
println(name, " arriving at ", now(env))
396
-
@yield request(bcs)
396
+
@yield lock(bcs)
397
397
println(name, " starting to charge at ", now(env))
0 commit comments