ox

package ox

Members list

Concise view

Type members

Classlikes

trait Fork[T]

A running fork, started using fork or forkHold, backend by a thread.

A running fork, started using fork or forkHold, backend by a thread.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
class ForkLocal[T](scopedValue: ScopedValue[T], default: T)

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
object ForkLocal

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
case class Ox(scope: StructuredTaskScope[Any], scopeThread: Thread, forkFailureToPropagate: AtomicReference[Throwable], finalizers: AtomicReference[List[() => Unit]])

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
object syntax

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
syntax.type

Value members

Concrete methods

def forever(f: => Unit): Nothing
def fork[T](f: => T)(using Ox): Fork[T]

Starts a thread, which is guaranteed to complete before the enclosing scoped block exits.

Starts a thread, which is guaranteed to complete before the enclosing scoped block exits.

Exceptions are propagated. In case an exception is thrown while evaluating t, the enclosing scope's main thread is interrupted and the exception is re-thrown there.

Attributes

def forkAllHold[T](fs: Seq[() => T])(using Ox): Fork[Seq[T]]
def forkHold[T](f: => T)(using Ox): Fork[T]

Starts a thread, which is guaranteed to complete before the enclosing scoped block exits.

Starts a thread, which is guaranteed to complete before the enclosing scoped block exits.

Exceptions are held. In case an exception is thrown while evaluating t, it will be thrown when calling the returned Fork's .join() method. The exception is not propagated to the enclosing scope's main thread, like in the case of fork.

Attributes

def par[T1, T2](t1: => T1)(t2: => T2): (T1, T2)

Runs the given computations in parallel. If any fails, interrupts the others, and re-throws the exception.

Runs the given computations in parallel. If any fails, interrupts the others, and re-throws the exception.

Attributes

def par[T1, T2, T3](t1: => T1)(t2: => T2)(t3: => T3): (T1, T2, T3)

Runs the given computations in parallel. If any fails, interrupts the others, and re-throws the exception.

Runs the given computations in parallel. If any fails, interrupts the others, and re-throws the exception.

Attributes

def par[T](ts: Seq[() => T]): Seq[T]

Runs the given computations in parallel. If any fails, interrupts the others, and re-throws the exception.

Runs the given computations in parallel. If any fails, interrupts the others, and re-throws the exception.

Attributes

def parLimit[T](concurrency: Int)(ts: Seq[() => T]): Seq[T]

Runs the given computations in parallel, with at most concurrency running concurrently at the same time. If any computation fails, interrupts the others, and re-throws the exception.

Runs the given computations in parallel, with at most concurrency running concurrently at the same time. If any computation fails, interrupts the others, and re-throws the exception.

Attributes

def raceResult[T](fs: Seq[() => T]): T
def raceResult[T](f1: => T)(f2: => T): T

Returns the result of the first computation to complete (either successfully or with an exception).

Returns the result of the first computation to complete (either successfully or with an exception).

Attributes

def raceSuccess[T](fs: Seq[() => T]): T
def raceSuccess[T](f1: => T)(f2: => T): T

Returns the result of the first computation to complete successfully, or if all fail - throws the first exception.

Returns the result of the first computation to complete successfully, or if all fail - throws the first exception.

Attributes

def repeatUntil(f: => Boolean): Unit

Repeat evaluating f until it evaluates to true.

Repeat evaluating f until it evaluates to true.

Attributes

def repeatWhile(f: => Boolean): Unit

Repeat evaluating f while it evaluates to true.

Repeat evaluating f while it evaluates to true.

Attributes

def retry[T](times: Int, sleep: FiniteDuration)(f: => T): T
def scoped[T](f: Ox ?=> T): T

Any child forks are interrupted after f completes.

Any child forks are interrupted after f completes.

Attributes

def timeout[T](duration: FiniteDuration)(t: => T): T
def uninterruptible[T](f: => T): T
def useCloseableInScope[T <: AutoCloseable](c: => T)(using Ox): T
def useInScope[T](acquire: => T)(release: T => Unit)(using Ox): T

Use the given resource in the current scope. The resource is allocated using acquire, and released after the scope is done using release. Releasing is uninterruptible.

Use the given resource in the current scope. The resource is allocated using acquire, and released after the scope is done using release. Releasing is uninterruptible.

Attributes

def useScoped[T, U](acquire: => T)(release: T => Unit)(b: T => U): U
def useScoped[T <: AutoCloseable, U](acquire: => T)(b: T => U): U