Ah, thanks for the clarification. A call to schedule(Task(task_func)) followed
by a yield() gave me the behavior I was expecting.

Why is it that yield() keeps the current task runnable but yieldto() does
not? My assumption was that the behavior would be similar except that
yield() lets the scheduler decide what to schedule next whereas yieldto()
would explicitly give which task to switch to. I'm happy to update the docs
to clarify my misunderstanding once I'm sure I understand. :)

-s


On Sat, Dec 21, 2013 at 10:52 AM, Jameson Nash <[email protected]> wrote:

> It hands control back to the Scheduler, as you expect, but the main
> context is no longer scheduled to run, so it will never return.
> Instead of calling `yieldto`, you can call `schedule` to start the
> task lazily. (or I think you could instead call
> `schedule(current_task())` just before the `yieldto` call so that your
> task is still runnable by the Scheduler)
>
> On Sat, Dec 21, 2013 at 5:33 AM, Spencer Russell <[email protected]> wrote:
> > When a Task waits does it block the whole Julia thread, or does it return
> > control to the scheduler to schedule in other tasks? See the following
> test
> > code:
> >
> > function task_test()
> >     function task()
> >         info("started task")
> >         wait()
> >     end
> >     info("about to start task")
> >     yieldto(Task(task))
> >     info("task yielded back to main context")
> > end
> >
> > I would expect the output of running task_test() to be
> >
> > about to start task
> > started task
> > task yielded back to main context
> >
> > but instead it seems that when the task waits, it doesn't hand control
> back
> > to the main context. I'm running this from the REPL, if that makes any
> > difference.
> >
> > -s
>

Reply via email to