On Thursday, September 3, 2015 at 1:48:33 AM UTC-4, Spencer Russell wrote: > > From the docs I gather that `@schedule operation()` is equivalent to > `schedule(@task operation())`, In that `operation()` will be wrapped in a > task and added as a runnable item in the scheduler queue. > > `@async` says it wraps the expression in a closure rather than a task, but > likewise adds it to the scheduler queue. It also adds it to the list of > things that the enclosing `@sync` is waiting for, so that’s definitely > another difference from `@schedule`
Hopefully you are trying to write better documentation for these things, like you mentioned in a previous thread; documentation improvements are always welcome. The best way to answer questions about under-documented functions is to look at the source, in this case https://github.com/JuliaLang/julia/blob/master/base/task.jl Both @async and @schedule create a closure and wrap it in a Task which is enqueued. Look at "macro async" vs. "macro schedule" ... they both do something like enq_work(Task(() -> expr)). The difference is that @async does two additional things. First, as you mentioned, it adds it to the @sync stack. Second, it calls "localize_vars" (defined in expr.jl), which wraps an expression in "let a=a, b=b, ..." for each variable it references; however, this second behavior is fairly likely to be changed, see: https://github.com/JuliaLang/julia/issues/7813 and https://github.com/JuliaLang/julia/issues/8591
