Resource

gears.async.Resource
See theResource companion trait
object Resource

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Resource.type

Members list

Value members

Concrete methods

def all[T](ress: List[Resource[T]]): Resource[List[T]]

Create a resource combining access to a list of resources

Create a resource combining access to a list of resources

Value parameters

ress

the list of single resources

Attributes

Returns

the resource of the list of elements provided by the single resources

inline def apply[T](inline alloc: Async ?=> T, inline close: T => Async ?=> Unit): Resource[T]

Create a Resource from the allocation and release operation. The returned resource will allocate a new instance, i.e., call alloc, for every call to use and allocated.

Create a Resource from the allocation and release operation. The returned resource will allocate a new instance, i.e., call alloc, for every call to use and allocated.

Value parameters

alloc

the allocation (generating) operation

close

the release (close) operation

Attributes

Returns

a new Resource exposing the allocatable object in a safe way

def both[T, U, V](res1: Resource[T], res2: Resource[U])(join: (T, U) => V): Resource[V]

Create a resource combining access to two separate resources.

Create a resource combining access to two separate resources.

Value parameters

join

an operator to combine the elements from both resources to that of the combined resource

res1

the first resource

res2

the second resource

Attributes

Returns

a new resource wrapping access to the combined element

inline def just[T](inline data: => T): Resource[T]

Create a resource that does not need asynchronous allocation nor cleanup.

Create a resource that does not need asynchronous allocation nor cleanup.

Value parameters

data

the generator that provides the resource element

Attributes

Returns

a resource wrapping the data provider

inline def spawning[T](inline spawnBody: Spawn ?=> T): Resource[T]

Create a concurrent computation resource from an allocator function. It can use the given capability to spawn Futures and return a handle to communicate with them. Allocation is only complete after that allocator returns. The resource is only allocated on use.

Create a concurrent computation resource from an allocator function. It can use the given capability to spawn Futures and return a handle to communicate with them. Allocation is only complete after that allocator returns. The resource is only allocated on use.

If the Async.Spawn capability is used for Async.awaiting, it may only be done synchronously by the spawnBody.

No presumption is made on reusability of the Resource. Thus, if the spawnBody is re-runnable, so is the Resource created from it.

Value parameters

spawnBody

the allocator to setup and start asynchronous computation

Attributes

Returns

a new resource wrapping access to the spawnBody's results