ox

package ox

Members list

Packages

package ox.channels

Type members

Classlikes

trait Fork[T]

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

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

Attributes

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

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object ForkLocal

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
ForkLocal.type
case class Ox(scope: StructuredTaskScope[Any], finalizers: AtomicReference[List[() => Unit]])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object syntax

Attributes

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.

In case an exception is thrown while evaluating t, it will be thrown when calling the returned Fork's .join() method.

Attributes

def forkAll[T](fs: Seq[() => T])(using Ox): Fork[Seq[T]]
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](parallelism: Int)(ts: Seq[() => T]): Seq[T]

Runs the given computations in parallel, with at most parallelism running in parallel 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 parallelism running in parallel at the same time. If any computation fails, interrupts the others, and re-throws the exception.

Attributes

def raceResult[T](fs: Seq[() => 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 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

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 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 retryEither[E, T](times: Int, sleep: FiniteDuration)(f: => Either[E, T]): Either[E, T]
def scoped[T](f: Ox ?=> T): T

Any child forks are interrupted after f completes. The method only completes when all child forks have completed.

Any child forks are interrupted after f completes. The method only completes when all child forks have completed.

Attributes

def timeout[T](duration: FiniteDuration)(t: => T): T

The result of computation t, if it took less than duration, and a TimeoutException otherwise.

The result of computation t, if it took less than duration, and a TimeoutException otherwise.

Attributes

Throws
TimeoutException

If t took more than duration.

def timeoutOption[T](duration: FiniteDuration)(t: => T): Option[T]

A Some if the computation t took less than duration, and None otherwise.

A Some if the computation t took less than duration, and None otherwise.

Attributes

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