Skip to content

Commit b8de238

Browse files
authored
priority for all Events is restored to Int; remove type signature on kwargs (#96)
1 parent bb72add commit b8de238

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

docs/src/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Private = false
66
```
77

88
```@docs
9-
unlock(res::Resource; priority::Number=0)
10-
take!(sto::Store, filter::Function=get_any_item; priority::Int=0)
9+
unlock(res::Resource; priority=0)
10+
take!(sto::Store, filter::Function=get_any_item; priority=0)
1111
```

src/base.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ function remove_callback(cb::Function, ev::AbstractEvent)
6363
i != 0 && deleteat!(ev.bev.callbacks, i)
6464
end
6565

66-
function schedule(ev::AbstractEvent, delay::Number=0; priority::Number=0, value::Any=nothing)
66+
function schedule(ev::AbstractEvent, delay::Number=0; priority=0, value=nothing)
6767
state(ev) === processed && throw(EventProcessed(ev))
6868
env = environment(ev)
6969
bev = ev.bev
7070
bev.value = value
71-
env.heap[bev] = EventKey(now(env) + delay, priority, env.sid+=one(UInt))
71+
env.heap[bev] = EventKey(now(env) + delay, Int(priority), env.sid+=one(UInt))
7272
bev.state = scheduled
7373
ev
7474
end

src/events.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ struct Event <: AbstractEvent
55
end
66
end
77

8-
function succeed(ev::Event; priority::Number=0, value::Any=nothing) :: Event
8+
function succeed(ev::Event; priority=0, value=nothing) :: Event
99
state(ev) !== idle && throw(EventNotIdle(ev))
10-
schedule(ev; priority=priority, value=value)
10+
schedule(ev; priority=Int(priority), value)
1111
end
1212

13-
function fail(ev::Event, exc::Exception; priority::Number=0) :: Event
14-
succeed(ev; priority=priority, value=exc)
13+
function fail(ev::Event, exc::Exception; priority=0) :: Event
14+
succeed(ev; priority=Int(priority), value=exc)
1515
end
1616

1717
struct Timeout <: AbstractEvent
@@ -21,8 +21,8 @@ struct Timeout <: AbstractEvent
2121
end
2222
end
2323

24-
function timeout(env::Environment, delay::Number=0; priority::Number=0, value::Any=nothing)
25-
schedule(Timeout(env), delay; priority=priority, value=value)
24+
function timeout(env::Environment, delay::Number=0; priority=0, value::Any=nothing)
25+
schedule(Timeout(env), delay; priority=Int(priority), value)
2626
end
2727

2828
function run(env::Environment, until::Number=Inf)

src/operators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function check(ev::AbstractEvent, op::Operator, event_state_values::Dict{Abstrac
3232
end
3333
elseif state(op) === scheduled
3434
if isa(val, Exception)
35-
schedule(op; priority=Inf, value=val)
35+
schedule(op; priority=typemax(Int), value=val)
3636
else
3737
event_state_values[ev] = StateValue(state(ev), val)
3838
end

src/processes.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ end
5757
function interrupt(proc::Process, cause::Any=nothing)
5858
env = environment(proc)
5959
if proc.fsmi._state !== 0xff
60-
proc.target isa Initialize && schedule(proc.target; priority=Inf)
61-
target = schedule(Interrupt(env); priority=Inf, value=InterruptException(active_process(env), cause))
60+
proc.target isa Initialize && schedule(proc.target; priority=typemax(Int))
61+
target = schedule(Interrupt(env); priority=typemax(Int), value=InterruptException(active_process(env), cause))
6262
@callback execute_interrupt(target, proc)
6363
end
64-
timeout(env; priority=Inf)
64+
timeout(env; priority=typemax(Int))
6565
end

src/simulations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ end
88

99
struct EmptySchedule <: Exception end
1010

11-
struct EventKey{N<:Number}
11+
struct EventKey
1212
time :: Float64
13-
priority :: N
13+
priority :: Int
1414
id :: UInt
1515
end
1616

src/utils/time.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ function run(env::Environment, until::DateTime)
66
run(env, Dates.datetime2epochms(until))
77
end
88

9-
function timeout(env::Environment, delay::Period; priority::Number=0, value::Any=nothing)
9+
function timeout(env::Environment, delay::Period; priority=0, value=nothing)
1010
time = now(env)
1111
del = Dates.datetime2epochms(Dates.epochms2datetime(time)+delay)-time
12-
timeout(env, del; priority=priority, value=value)
12+
timeout(env, del; priority=Int(priority), value)
1313
end
1414

1515
function nowDatetime(env::Environment)

0 commit comments

Comments
 (0)