Commit Graph

12 Commits

Author SHA1 Message Date
Doug Gregor
4fb5f05f37 [Concurrency] More cleanups for futures 2020-11-14 15:18:54 -08:00
Doug Gregor
c0fd27fbe5 [Concurrency] Minor cleanups to futures. 2020-11-14 15:18:54 -08:00
Doug Gregor
7f3db7fbde [Concurrency] Have future functions write their results directly.
Introduce `FutureAsyncContext` to line up with the async context formed
by IR generation for the type `<T> () async throws -> T`. When allocating
a future task, set up the context with the address of the future's storage
for the successful result and null out the error result, so the caller
will directly fill in the result. This eliminates a bunch of extra
complexity and a copy.
2020-11-14 15:18:54 -08:00
Doug Gregor
19d9e0f4d4 [Concurrency] Clarify/fix error object handling in futures. 2020-11-14 15:18:54 -08:00
Doug Gregor
5538aafed8 [Concurrency] Inline AsyncTask::FutureFragment::fragmentSize. 2020-11-14 15:18:54 -08:00
Doug Gregor
91360f0785 [Concurrency] Turn "simple task" into just "task".
There isn't a big advantage to keeping "simple" task as a separate
concept from a task. Tasks may or may not have futures.
2020-11-14 15:18:54 -08:00
Doug Gregor
0ae6c6337e [Concurrency] Use SchedulerPrivate for the "next waiting task" link.
Reduce the size of AsyncTask by using the first slot of SchedulerPrivate
for the next waiting task. Thanks, John!
2020-11-14 15:18:54 -08:00
Doug Gregor
4b924673ce [Concurrency] Use a single atomic for future wait queue.
Use a single atomic for the wait queue that combines the status with
the first task in the queue. Address race conditions in waiting and
completing the future.

Thanks to John for setting the direction here for me.
2020-11-14 15:18:54 -08:00
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
Arnold Schwaighofer
e51575b1df Silence an assert 2020-11-13 15:59:43 -08:00
Arnold Schwaighofer
193a3d5a8f Temporarily add runAsync to run a task synchronously in the current thread
Add a temporary runtime entry to run a task synchronous.
2020-11-13 10:41:42 -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