Skip to content

Commit

Permalink
docstring added
Browse files Browse the repository at this point in the history
  • Loading branch information
pbayer committed Feb 27, 2020
1 parent 4d1bc67 commit 192e595
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@
# Paul Bayer, 2020
# license: MIT
#
"""
onthread(f::F, id::Int) where {F<:Function}
Execute a function f on thread id.
# Examples, usage
```julia
julia> using ThreadingExperiments, .Threads
julia> onthread(threadid, 2)
2
julia> onthread(3) do; threadid(); end
3
julia> onthread(4) do
threadid()
end
4
```
"""
function onthread(f::F, id::Int) where {F<:Function}
t = Task(nothing)
@assert id in 1:nthreads() "thread $id not available!"
Expand Down

0 comments on commit 192e595

Please sign in to comment.