Skip to content

Commit 9524aea

Browse files
authored
Merge pull request #60 from jvkerckh/master
Changed the type of process priorities from Int8 to Int (Julia v0.7+)
2 parents 208d4ca + 55b986c commit 9524aea

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ 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=zero(Float64); priority::Int8=zero(Int8), value::Any=nothing)
66+
function schedule(ev::AbstractEvent, delay::Number=zero(Float64); priority::Int=0, value::Any=nothing)
6767
state(ev) == processed && throw(EventProcessed(ev))
6868
env = environment(ev)
6969
bev = ev.bev

src/events.jl

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

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

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

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

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

2828
function run(env::Environment, until::Number=typemax(Float64))
2929
run(env, timeout(env, until-now(env)))
30-
end
30+
end

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=typemax(Int8), 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=typemax(Int8))
61-
target = schedule(Interrupt(env); priority=typemax(Int8), 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=typemax(Int8))
64+
timeout(env; priority=typemax(Int))
6565
end

src/simulations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct EmptySchedule <: Exception end
1010

1111
struct EventKey
1212
time :: Float64
13-
priority :: Int8
13+
priority :: Int
1414
id :: UInt
1515
end
1616

src/utils/time.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function run(env::Environment, until::DateTime)
66
run(env, Dates.datetime2epochms(until))
77
end
88

9-
function timeout(env::Environment, delay::Period; priority::Int8=zero(Int8), value::Any=nothing)
9+
function timeout(env::Environment, delay::Period; priority::Int=0, value::Any=nothing)
1010
time = now(env)
1111
del = Dates.datetime2epochms(Dates.epochms2datetime(time)+delay)-time
1212
timeout(env, del; priority=priority, value=value)

0 commit comments

Comments
 (0)