diff --git a/src/resources/containers.jl b/src/resources/containers.jl index 9635dec..fcbced0 100755 --- a/src/resources/containers.jl +++ b/src/resources/containers.jl @@ -1,5 +1,5 @@ struct ContainerKey{N<:Real} <: ResourceKey - priority :: Int + priority :: Real id :: UInt amount :: N end @@ -22,7 +22,7 @@ end const Resource = Container{Int} -function put(con::Container{N}, amount::N; priority::Int=0) where N<:Real +function put(con::Container{N}, amount::N; priority::Real=0) where N<:Real put_ev = Put(con.env) con.put_queue[put_ev] = ContainerKey(priority, con.seid+=one(UInt), amount) @callback trigger_get(put_ev, con) @@ -30,9 +30,9 @@ function put(con::Container{N}, amount::N; priority::Int=0) where N<:Real put_ev end -request(res::Resource; priority::Int=0) = put(res, 1; priority=priority) +request(res::Resource; priority::Real=0) = put(res, 1; priority=priority) -function get(con::Container{N}, amount::N; priority::Int=0) where N<:Real +function get(con::Container{N}, amount::N; priority::Real=0) where N<:Real get_ev = Get(con.env) con.get_queue[get_ev] = ContainerKey(priority, con.seid+=one(UInt), amount) @callback trigger_put(get_ev, con) @@ -40,7 +40,7 @@ function get(con::Container{N}, amount::N; priority::Int=0) where N<:Real get_ev end -release(res::Resource; priority::Int=0) = get(res, 1; priority=priority) +release(res::Resource; priority::Real=0) = get(res, 1; priority=priority) function do_put(con::Container{N}, put_ev::Put, key::ContainerKey{N}) where N<:Real con.level + key.amount > con.capacity && return false diff --git a/src/resources/stores.jl b/src/resources/stores.jl index 72fb70a..4b9738f 100755 --- a/src/resources/stores.jl +++ b/src/resources/stores.jl @@ -1,12 +1,12 @@ struct StorePutKey{T} <: ResourceKey - priority :: Int + priority :: Real id :: UInt item :: T StorePutKey{T}(priority, id, item) where T = new(priority, id, item) end struct StoreGetKey <: ResourceKey - priority :: Int + priority :: Real id :: UInt filter :: Function end @@ -24,7 +24,7 @@ mutable struct Store{T} <: AbstractResource end end -function put(sto::Store{T}, item::T; priority::Int=0) where T +function put(sto::Store{T}, item::T; priority::Real=0) where T put_ev = Put(sto.env) sto.put_queue[put_ev] = StorePutKey{T}(priority, sto.seid+=one(UInt), item) @callback trigger_get(put_ev, sto) @@ -34,7 +34,7 @@ end get_any_item(::T) where T = true -function get(sto::Store{T}, filter::Function=get_any_item; priority::Int=0) where T +function get(sto::Store{T}, filter::Function=get_any_item; priority::Real=0) where T get_ev = Get(sto.env) sto.get_queue[get_ev] = StoreGetKey(priority, sto.seid+=one(UInt), filter) @callback trigger_put(get_ev, sto)