Commit Graph

104 Commits

Author SHA1 Message Date
Doug Gregor
85d003ef9b [Concurrency] Implement basic runtime support for task futures.
Extend AsyncTask and the concurrency runtime with basic support for
task futures. AsyncTasks with futures contain a future fragment with
information about the type produced by the future, and where the
future will put the result value or the thrown error in the initial
context.

We still don't have the ability to schedule the waiting tasks on an
executor when the future completes, so this isn't useful for anything
just test, and we can only test limited code paths.
2020-11-14 15:18:54 -08:00
Doug Gregor
c291eb596b [Concurrency] Add cancelAsyncTask() builtin.
Implement a new builtin, `cancelAsyncTask()`, to cancel the given
asynchronous task. This lowers down to a call into the runtime
operation `swift_task_cancel()`.

Use this builtin to implement Task.Handle.cancel().
2020-11-05 13:50:17 -08:00
John McCall
a06d18ce81 Add API for creating unscheduled tasks.
Make all tasks into heap objects.
2020-10-22 00:53:16 -04:00
John McCall
8ac4362754 Implement a simple library for task cancellation and status management.
There are things about this that I'm far from sold on.  In
particular, I'm concerned that in order to implement escalation
correctly, we're going to have to add a status record for the
fact that the task is being executed, which means we're going
to have to potentially wait to acquire the status lock; overall,
that means making an extra runtime function call and doing some
atomics whenever we resume or suspend a task, which is an
uncomfortable amount of overhead.

The testing here is pretty grossly inadequate, but I wanted to
lay down the groundwork here.
2020-10-15 00:36:36 -04:00