Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pbayer committed Sep 13, 2020
2 parents 3e3baef + 33612d7 commit bdd2d5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 0 additions & 6 deletions src/process.jl
Expand Up @@ -6,12 +6,6 @@
# This is a Julia package for discrete event simulation
#

# @static if VERSION >= v"1.3"
# using Base.Threads: @spawn
# else
# @eval const $(Symbol("@spawn")) = $(Symbol("@async"))
# end

# Register a Prc to a clock. Check its id and change it apropriately.
function _register!(clk::Clock, p::Prc)
id = p.id
Expand Down
17 changes: 12 additions & 5 deletions src/types.jl
Expand Up @@ -101,20 +101,26 @@ struct PrcException{U,V} <: Exception
end

"""
Prc(id, f, arg...; kw...)
```
Prc(id, f, arg...; kw...)
Prc(f, arg...; kw...)
```
Prepare a function to run as a process and get registered to a clock.
# Arguments, Fields
- `id`: some unique identification for registration,
- `id`: some unique identification for registration,
- `f::Function`: a function `f(clk, arg...; kw...)`, must take `clk`
(a [`Clock`](@ref)) as its first argument,
- `arg...`: further arguments to `f`
- `kw...`: keyword arguments to `f`
# Dynamically Identified Fields
# Fields identified during registration
- `id`: if it is not provided, some integer will be calculated
for it during registration,
- `task::Union{Task,Nothing}`: a task structure used for diagnosis,
- `clk::Union{AbstractClock,Nothing}`: clock where the process is registered,
- `clk::Union{AbstractClock,Nothing}`: clock where the process is
registered,
!!! note "The clock is identified dynamically!"
Expand All @@ -130,7 +136,8 @@ mutable struct Prc
arg::Tuple
kw::Base.Iterators.Pairs

Prc(id, f::Function, arg...; kw...) = new(id, nothing, nothing, f, arg, kw)
Prc( id, f::Function, arg...; kw...) = new(id, nothing, nothing, f, arg, kw)
Prc(f::Function, arg...; kw...) = new(1, nothing, nothing, f, arg, kw)
end

"""
Expand Down

0 comments on commit bdd2d5f

Please sign in to comment.