Skip to content

Commit c1585df

Browse files
authored
Add @fetch and @fetchfrom macros
1 parent a75c1bd commit c1585df

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/internals.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,24 @@ macro spawnat(thrdid, ex)
117117
end
118118
end
119119

120+
"""
121+
@fetch ex
122+
123+
Shortcut for `fetch(@spawn(ex))`.
124+
"""
125+
macro fetch(ex)
126+
:(fetch(@spawn($(esc(ex)))))
127+
end
128+
129+
"""
130+
@fetchfrom thrdid ex
131+
132+
Shortcut for `fetch(@spawnat(thrdid, ex))`.
133+
"""
134+
macro fetchfrom(thrdid, ex)
135+
:(fetch(@spawnat($(esc(thrdid)), $(esc(ex)))))
136+
end
137+
120138
# Copied from base rather than calling it directly because who knows if it'll change in the future
121139
function _lift_one_interp!(e)
122140
letargs = Any[] # store the new gensymed arguments

0 commit comments

Comments
 (0)