Skip to content

Commit 0db391d

Browse files
committed
Make threaded the second type parameter to reduce typing
1 parent 284dc88 commit 0db391d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/model.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
struct Model{F,argnames,defaultnames,missings,Targs,Tdefaults,Ctx<:AbstractContext,Threaded}
2+
struct Model{F,Threaded,argnames,defaultnames,missings,Targs,Tdefaults,Ctx<:AbstractContext}
33
f::F
44
args::NamedTuple{argnames,Targs}
55
defaults::NamedTuple{defaultnames,Tdefaults}
@@ -38,7 +38,7 @@ Model{typeof(f),(:x, :y),(:x,),(:y,),Tuple{Float64,Float64},Tuple{Int64}}(f, (x
3838
```
3939
"""
4040
struct Model{
41-
F,argnames,defaultnames,missings,Targs,Tdefaults,Ctx<:AbstractContext,Threaded
41+
F,Threaded,argnames,defaultnames,missings,Targs,Tdefaults,Ctx<:AbstractContext
4242
} <: AbstractProbabilisticProgram
4343
f::F
4444
args::NamedTuple{argnames,Targs}
@@ -56,8 +56,8 @@ struct Model{
5656
args::NamedTuple{argnames,Targs},
5757
defaults::NamedTuple{defaultnames,Tdefaults},
5858
context::Ctx=DefaultContext(),
59-
) where {missings,F,argnames,Targs,defaultnames,Tdefaults,Ctx,Threaded}
60-
return new{F,argnames,defaultnames,missings,Targs,Tdefaults,Ctx,Threaded}(
59+
) where {Threaded,missings,F,argnames,Targs,defaultnames,Tdefaults,Ctx}
60+
return new{F,Threaded,argnames,defaultnames,missings,Targs,Tdefaults,Ctx}(
6161
f, args, defaults, context
6262
)
6363
end
@@ -94,11 +94,12 @@ function Model{Threaded}(
9494
return Model{Threaded}(f, args, NamedTuple(kwargs), context)
9595
end
9696

97-
function _requires_threadsafe(
98-
::Model{F,A,D,M,Ta,Td,Ctx,Threaded}
99-
) where {F,A,D,M,Ta,Td,Ctx,Threaded}
100-
return Threaded
101-
end
97+
"""
98+
_requires_threadsafe(model::Model{F,Threaded}) where {F,Threaded}
99+
100+
Return whether `model` has been marked as needing threadsafe evaluation.
101+
"""
102+
_requires_threadsafe(::Model{F,Threaded}) where {F,Threaded} = Threaded
102103

103104
"""
104105
contextualize(model::Model, context::AbstractContext)

0 commit comments

Comments
 (0)