Import std.concurrent.tasks
ThrowingTaskSource
class
Public Class ThrowingTaskSource<T, E: Error>
A Task finished by hand that can throw: Finish gives its Task the result, and Fail the error, which a Wait or an Await on the Task then gives or throws. An error isn't Sendable, so it's a Class, which stays on the main thread, as its Tasks do; work on other threads finishes a TaskSource instead. One that's never finished leaves its Task never done.
Examples
Local source = ThrowingTaskSource<Int, ParseError>()
Local task = source.Task
source.Fail(ParseError(ParseErrorKind.SYNTAX, "not a number"))
Expect(ExpectThrows<ParseError>(task.Wait()) != Null)std/concurrent/tasks.fb, line 107
-
A new ThrowingTaskSource, whose Task isn't done.
-
A Task of the result, or of the error: done at once when Finish or Fail has given it, and otherwise at the main thread's first tick after it does. Each one it gives is a new Task of the same result.
-
Whether Finish or Fail has given its Task what it gives.
-
Gives the Task its result, which wakes what waits for it. Panics when it has a result or an error already.
-
Gives the Task its error, which a Wait or an Await on it throws. Panics when it has a result or an error already.
-
Gives the Task its result unless it has a result or an error already, and tells whether it didn't.
-
Gives the Task its error unless it has a result or an error already, and tells whether it didn't.
Report an issue with this page or with FutureBlitz on GitHub.