Skip to content

Commit 3410a36

Browse files
committed
deprecate ConcurrentSim.release in favor of Base.unlock
1 parent 5827540 commit 3410a36

File tree

9 files changed

+14
-15
lines changed

9 files changed

+14
-15
lines changed

benchmark/old_processes_MM1.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function customer(sim::Simulation, server::Resource, mu::Float64)
1212
yield(lock(server))
1313
dt = rand(Exponential(1/mu))
1414
yield(timeout(sim, dt))
15-
yield(release(server))
15+
yield(unlock(server))
1616
end
1717

1818
function customer2(sim::Simulation, server::Resource, mu::Float64)

benchmark/processes_MM1.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212
@yield lock(server)
1313
dt = rand(Exponential(1 / mu))
1414
@yield timeout(sim, dt)
15-
@yield release(server)
15+
@yield unlock(server)
1616
end
1717

1818
function test_mm1(n::Float64)

docs/src/examples/mmc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ service_dist = Exponential(1 / mu) # service time distribution
2525
@yield lock(server) # customer starts service
2626
println("Customer $id entered service: ", now(env))
2727
@yield timeout(env, rand(d_s)) # server is busy
28-
@yield release(server) # customer exits service
28+
@yield unlock(server) # customer exits service
2929
println("Customer $id exited service: ", now(env))
3030
end
3131

docs/src/examples/ross.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const G = Exponential(MU)
4646
end
4747
@yield lock(repair_facility)
4848
@yield timeout(env, rand(rng, G))
49-
@yield release(repair_facility)
49+
@yield unlock(repair_facility)
5050
@yield put!(spares, active_process(env))
5151
end
5252
end

docs/src/tutorial.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ julia> @resumable function car(env::Environment, name::Int, bcs::Resource, drivi
305305
println(name, " starting to charge at ", now(env))
306306
@yield timeout(sim, charge_duration)
307307
println(name, " leaving the bcs at ", now(env))
308-
@yield release(bcs)
308+
@yield unlock(bcs)
309309
end
310310
car (generic function with 1 method)
311311
```
312312

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.
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 with `unlock`.
314314

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.
315+
You are responsible to call `unlock` once you are done using the resource. When you unlock (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.
316316

317317
A resource needs a reference to an `Environment` and a capacity when it is created:
318318

@@ -328,7 +328,7 @@ DocTestSetup = quote
328328
println(name, " starting to charge at ", now(env))
329329
@yield timeout(sim, charge_duration)
330330
println(name, " leaving the bcs at ", now(env))
331-
@yield release(bcs)
331+
@yield unlock(bcs)
332332
end
333333
end
334334
```
@@ -355,7 +355,7 @@ DocTestSetup = quote
355355
println(name, " starting to charge at ", now(env))
356356
@yield timeout(sim, charge_duration)
357357
println(name, " leaving the bcs at ", now(env))
358-
@yield release(bcs)
358+
@yield unlock(bcs)
359359
end
360360
361361
sim = Simulation()
@@ -397,7 +397,7 @@ DocTestSetup = quote
397397
println(name, " starting to charge at ", now(env))
398398
@yield timeout(sim, charge_duration)
399399
println(name, " leaving the bcs at ", now(env))
400-
@yield release(bcs)
400+
@yield unlock(bcs)
401401
end
402402
403403
sim = Simulation()

src/ConcurrentSim.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module ConcurrentSim
1717
export @resumable, @yield
1818
export AbstractProcess, Simulation, run, now, active_process, StopSimulation
1919
export Process, @process, interrupt
20-
export Container, Resource, Store, put!, get, release, cancel
20+
export Container, Resource, Store, put!, get, cancel
2121
export nowDatetime
2222

2323
include("base.jl")

src/deprecated.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Base.@deprecate put(args...) put!(args...)
22
Base.@deprecate request(args...; kwargs...) lock(args...; kwargs...)
3+
Base.@deprecate release(args...; kwargs...) unlock(args...; kwargs...)

src/resources/containers.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function get(con::Container{N}, amount::N; priority::Int=0) where N<:Real
4040
get_ev
4141
end
4242

43-
release(res::Resource; priority::Int=0) = get(res, 1; priority=priority)
43+
unlock(res::Resource; priority::Int=0) = get(res, 1; priority=priority)
4444

4545
function do_put(con::Container{N}, put_ev::Put, key::ContainerKey{N}) where N<:Real
4646
con.level + key.amount > con.capacity && return false
@@ -88,5 +88,3 @@ true
8888
```
8989
"""
9090
islocked(c::Container) = c.level==c.capacity
91-
92-
unlock(c::Container) = release(c)

test/test_resources_containers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using ResumableFunctions
77
println("$(now(sim)), client $i is being served")
88
@yield timeout(sim, rand())
99
println("$(now(sim)), client $i has been served")
10-
@yield release(res)
10+
@yield unlock(res)
1111
end
1212

1313
@resumable function generate(sim::Simulation, res::Resource)

0 commit comments

Comments
 (0)