Attributes
Members list
Type members
Classlikes
An original source has a standard definition of onComplete in terms of poll and addListener.
An original source has a standard definition of onComplete in terms of poll and addListener.
Implementations should be the resource owner to handle listener queue and completion using an object monitor on the instance.
Attributes
- Supertypes
- Known subtypes
An asynchronous data source. Sources can be persistent or ephemeral. A persistent source will always pass same data to calls of Source!.poll and Source!.onComplete. An ephemeral source can pass new data in every call.
An asynchronous data source. Sources can be persistent or ephemeral. A persistent source will always pass same data to calls of Source!.poll and Source!.onComplete. An ephemeral source can pass new data in every call.
Attributes
- See also
-
An example of a persistent source is gears.async.Future.
An example of an ephemeral source is gears.async.Channel.
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Types
Cases for handling async sources in a select. SelectCase can be constructed by extension methods handle
of Source.
Cases for handling async sources in a select. SelectCase can be constructed by extension methods handle
of Source.
Attributes
- See also
-
Source.handle (and its operator alias ~~>)
Async.select where SelectCase is used.
Async.Spawn is a special subtype of Async, also capable of spawning runnable Futures.
Async.Spawn is a special subtype of Async, also capable of spawning runnable Futures.
Most functions should not take Spawn as a parameter, unless the function explicitly wants to spawn "dangling" runnable Futures. Instead, functions should take Async and spawn scoped futures within Async.group.
Attributes
Value members
Concrete methods
Execute asynchronous computation body
on currently running thread. The thread will suspend when the computation waits.
Execute asynchronous computation body
on currently running thread. The thread will suspend when the computation waits.
Attributes
Returns the currently executing Async context. Equivalent to summon[Async]
.
Returns the currently executing Async context. Equivalent to summon[Async]
.
Attributes
Race two sources, wrapping them respectively in Left and Right cases.
Runs body
inside a spawnable context where it is allowed to spawn concurrently runnable Futures. When the body returns, all spawned futures are cancelled and waited for.
Runs body
inside a spawnable context where it is allowed to spawn concurrently runnable Futures. When the body returns, all spawned futures are cancelled and waited for.
Attributes
Creates a source that "races" a list of sources.
Creates a source that "races" a list of sources.
Listeners attached to this source is resolved with the first item arriving from one of the sources. If multiple sources are available at the same time, one of the items will be returned with no priority. Items that are not returned are '''not''' consumed from the upstream sources.
Attributes
- See also
-
raceWithOrigin for a race source that also returns the upstream origin of the item.
Async.select for a convenient syntax to race sources and awaiting them with Async.
Like race, but the returned value includes a reference to the upstream source that the item came from.
Like race, but the returned value includes a reference to the upstream source that the item came from.
Attributes
- See also
-
Async.select for a convenient syntax to race sources and awaiting them with Async.
Race a list of sources with the corresponding handler functions, once an item has come back. Like race, select guarantees exactly one of the sources are polled. Unlike transformValuesWith, the handler in select is run in the same async context as the calling context of select.
Race a list of sources with the corresponding handler functions, once an item has come back. Like race, select guarantees exactly one of the sources are polled. Unlike transformValuesWith, the handler in select is run in the same async context as the calling context of select.
Attributes
- See also
-
Source.handle (and its operator alias ~~>) for methods to create SelectCases.
- Example
-
// Race a channel read with a timeout val ch = SyncChannel[Int]() // ... val timeout = Future(sleep(1500.millis)) Async.select( ch.readSrc.handle: item => Some(item * 2), timeout ~~> _ => None )
Extensions
Extensions
Waits for an item to arrive from the source, then automatically unwraps it. Suspends until an item returns.
Waits for an item to arrive from the source, then automatically unwraps it. Suspends until an item returns.
Attributes
- See also
-
awaitResult for non-unwrapping await.
Waits for an item to arrive from the source, then automatically unwraps it. Suspends until an item returns.
Waits for an item to arrive from the source, then automatically unwraps it. Suspends until an item returns.
Attributes
- See also
-
awaitResult for non-unwrapping await.
Create a new source that requires the original source to run the given transformation function on every value received.
Create a new source that requires the original source to run the given transformation function on every value received.
Note that f
is always run on the computation that produces the values from the original source, so this is very likely to run sequentially and be a performance bottleneck.
Value parameters
- f
-
the transformation function to be run on every value.
f
is run before the item is passed to the Listener.
Attributes
Attach a handler to src
, creating a SelectCase.
Attach a handler to src
, creating a SelectCase.
Attributes
- See also
-
Async.select where SelectCase is used.
Alias for handle