gears.async.Future
See theFuture companion object
trait Future[+T] extends OriginalSource[Try[T]], Cancellable
Futures are Sources that has the following properties:
- They represent a single value: Once resolved, await-ing on a Future should always return the same value.
- They can potentially be cancelled, via the cancel method.
There are two kinds of futures, active and passive.
- '''Active''' futures are ones that are spawned with Future.apply and Task.start. They require the Async.Spawn context, and run on their own (as long as the Async.Spawn scope has not ended). Active futures represent concurrent computations within Gear's structured concurrency tree. Idiomatic Gears code should ''never'' return active futures. Should a function be async (i.e. takes an Async context parameter), they should return values or throw exceptions directly.
- '''Passive''' futures are ones that are created by Future.Promise (through asFuture) and Future.withResolver. They represent yet-arrived values coming from ''outside'' of Gear's structured concurrency tree (for example, from network or the file system, or even from another concurrency system like Scala standard library futures). Idiomatic Gears libraries should return this kind of Future if deemed neccessary, but functions returning passive futures should ''not'' take an Async context.
Attributes
- See also
-
Future.apply and Task.start for creating active futures.
Future.Promise and Future.withResolver for creating passive futures.
Future.awaitAll, Future.awaitFirst and Future.Collector for tools to work with multiple futures.
ScalaConverters.asGears and ScalaConverters.asScala for converting between Scala futures and Gears futures.
- Companion
- object
- Graph
-
- Supertypes
- Known subtypes
-
trait Promise[T]
Members list
In this article