Work that has not run: a description to start, and one run of it to wait for.
A description of work that will answer with a Value.
Building one runs nothing. start puts it in flight and answers the one run of it, and complete waits for what it answers with. A Future can be started any number of times, and each start is a fresh run.
A Function whose body writes complete declares -> Future<Value>. Calling it is an ordinary call that builds the future without running any of it.
Answers a Future that runs the given Function when it is started.
Nothing runs while the Future is being built. Each start calls the Function again, so two starts answer two values, and a Function reading something that changes reads it at each start.
The Function runs on the Program's own thread, from beginning to end, with nothing else in between. It is the way to describe a computation as work rather than to carry one out somewhere else.
NameTypeDescription
_() -> Valuethe computation to run when the Future is started
Returns a Future answering what the computation answers.
Answers a Future that runs this one and hands its value to the transform.
Nothing runs while the answer is being built. Each start of the answer starts the receiver again, so two starts run the work twice and call the transform twice.
NameTypeDescription
_(_: Value) -> Otherthe transform the value is handed to
Returns a Future answering what the transform answers.
Answers a Future that runs this one, and answers nothing where it takes too long.
The run is stopped at the deadline. It was started by this Method and nothing else can be waiting for it, so what it would have answered is never read.
The answer is an Optional rather than a failure, because a deadline is a question the caller asked rather than something that went wrong.
NameTypeDescription
millisecondsIntegerhow long the run has
Returns the value, or nothing where the deadline passed first.
Answers the same run, giving up on it after the given number of milliseconds.
The run is not stopped. A Started can be completed from anywhere, so a deadline one holder writes can not stop the work another is waiting for. The waiting stops and the work goes on.
A host with an event loop stays open until that work is over. Giving up on an answer is not giving up on the run, so a Program can not exit ahead of it.
The time is counted from here, because the run is in flight already.
NameTypeDescription
millisecondsIntegerhow long to wait for it
Returns the value, or nothing where the deadline passed first.
Answers a Future running every one of them in order, each started once the one before it has answered.
The answer holds one value per item, in the receiver's order. The empty List answers the empty List.
This is the entry for work that is not independent. A host can refuse a second request at once, and a walk can have an order that is what the answer means.
Answers a Future starting every one of them at once, and answering with the value of the first that answers one.
A run that fails is not an answer, and the waiting goes on. Every other run is stopped as soon as one has answered a value.
A List whose every run failed answers nothing, and so does the empty List. The name is OptionalList::firstValue's, for the same question one level along.
Returns the first value, or nothing where every run failed.