Skip to content

Commit 96b2c6b

Browse files
committed
thunk: Dont move (error,value) tuple
1 parent 44913e8 commit 96b2c6b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/thunk.jl

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ Base.wait(t::ThunkFuture) = Dagger.Sch.thunk_yield() do
154154
end
155155
function Base.fetch(t::ThunkFuture; proc=OSProc(), raw=false)
156156
error, value = Dagger.Sch.thunk_yield() do
157-
if raw
158-
fetch(t.future)
159-
else
160-
move(proc, fetch(t.future))
161-
end
157+
fetch(t.future)
162158
end
163159
if error
164160
throw(value)
165161
end
166-
value
162+
if raw
163+
return value
164+
else
165+
return move(proc, value)
166+
end
167167
end
168168
Base.put!(t::ThunkFuture, x; error=false) = put!(t.future, (error, x))
169169

@@ -263,13 +263,7 @@ mutable struct EagerThunk
263263
end
264264
Base.isready(t::EagerThunk) = isready(t.future)
265265
Base.wait(t::EagerThunk) = wait(t.future)
266-
function Base.fetch(t::EagerThunk; raw=false)
267-
if raw
268-
fetch(t.future; raw=true)
269-
else
270-
move(OSProc(), fetch(t.future))
271-
end
272-
end
266+
Base.fetch(t::EagerThunk; raw=false) = fetch(t.future; raw)
273267
function Base.show(io::IO, t::EagerThunk)
274268
print(io, "EagerThunk ($(isready(t) ? "finished" : "running"))")
275269
end

0 commit comments

Comments
 (0)