Skip to content

Commit

Permalink
Allow non-Functions as thunk kernel argument (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsamaroo committed Oct 30, 2020
1 parent 398b2e6 commit 9fa84ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/thunk.jl
Expand Up @@ -7,7 +7,7 @@ end

# A thing to run
mutable struct Thunk
f::Function
f::Any # usually a Function, but could be any callable
inputs::Tuple
id::Int
get_result::Bool # whether the worker should send the result or only the metadata
Expand Down
12 changes: 12 additions & 0 deletions test/processors.jl
Expand Up @@ -91,6 +91,18 @@ end

wait(rmprocs(ps))
end

@testset "Callable as Thunk function" begin
@everywhere begin
struct ABC end
(::ABC)(x) = x+1
end

abc = ABC()
a = delayed(abc)(1)
@test collect(a) == 2
end

@testset "Processor TLS accessor" begin
@everywhere function mythunk(x)
typeof(Dagger.thunk_processor())
Expand Down

0 comments on commit 9fa84ec

Please sign in to comment.