I read this article from hacker news about
today and decided to see how well the concepts there mapped to scheduled
in Julia (I haven’t had occasion to use
Tasks myself yet). To my
gratification, the approach to asyncronicity advocated in the article already
one of the most natural ways to do async in Julia.
For those who don’t have time to read the article, it basically argues that
scheduling a Task/coroutine to run on a “background” thread (
Julia) is a misfeature in much the same way as
goto is a misfeature: both, if
they occur inside a function break assumptions programmers usually make about
the effects of calling a function in a way that cannot be distinguished at the
call-site. As an example in Julia, consider if somewhere deep in the dark
crevasses of a library you’re using, a function
schedules something that never
yields; since Julia has a single global scheduler (afaict), anything you
scheduled after that would never run.
So if we accept that ad-hoc scheduling is a misfeature, what’s the minimum set
of changes we’d need to make to Julia to get rid of it while still allowing
schedulefor use in library code.
@asyncso that it only
Tasks when inside a
- (Optional) Implement error propagation as described in the linked article.
As far as I can tell, that’s it (I’m sure there’s something I’m missing). Any
thoughts? Is there something you can currently do with
@schedule that couldn’t
be done by wrapping it up in a
@sync block? If so, should that be done?