Skip to content

Commit 74bf47e

Browse files
authored
Merge pull request #71 from JuliaGPU/vc/event_async
Run Event(f) on main thread
2 parents 8a95e72 + 0935642 commit 74bf47e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "KernelAbstractions"
22
uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
33
authors = ["Valentin Churavy <[email protected]>"]
4-
version = "0.1.4"
4+
version = "0.1.5"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/backends/cpu.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ function Event(::CPU)
66
return NoneEvent()
77
end
88

9-
function Event(f, args...; dependencies=nothing, progress=nothing)
10-
T = Threads.@spawn begin
9+
"""
10+
Event(f, args...; dependencies, progress, sticky=true)
11+
12+
Run function `f` with `args` in a Julia task. If `sticky` is `true` the task
13+
is run on the thread that launched it.
14+
"""
15+
function Event(f, args...; dependencies=nothing, progress=nothing, sticky=true)
16+
T = Task() do
1117
wait(MultiEvent(dependencies), progress)
1218
f(args...)
1319
end
20+
T.sticky = sticky
21+
Base.schedule(T)
1422
return CPUEvent(T)
1523
end
1624

0 commit comments

Comments
 (0)