ox
Members list
Type members
Classlikes
A fork started using forkCancellable, backed by a (virtual) thread.
An error mode where errors are represented as Either[E, T]
instances.
An error mode where errors are represented as Either[E, T]
instances.
Attributes
- Supertypes
Describes the representation of application errors. Such errors have type E
and are reported in context F
.
Describes the representation of application errors. Such errors have type E
and are reported in context F
.
An application error is a value which is returned as a successful completion of a fork. However, unlike regular values, such error values are reported and cause the enclosing scope to end.
For any type T
, F[T]
represents a value which might either:
- be successful; in that case, a
T
instance can be derived - be an error; in that case, an
E
instance can be derived
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
A fork started using fork, forkError, forkUser, forkUserError, forkCancellable or forkUnsupervised, backed by a (virtual) thread.
A fork started using fork, forkError, forkUser, forkUserError, forkCancellable or forkUnsupervised, backed by a (virtual) thread.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait CancellableFork[T]
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
An error mode which doesn't allow reporting application errors.
An error mode which doesn't allow reporting application errors.
However, forks can still fail by throwing exceptions.
Attributes
- Supertypes
- Self type
-
NoErrorMode.type
Represents a capability to fork asynchronously running computations in a concurrency scope created using supervised or scoped.
Represents a capability to fork asynchronously running computations in a concurrency scope created using supervised or scoped.
Attributes
- See also
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
Represents a capability to fork asynchronously running computations in a concurrency scope created using supervisedError. This is similar to Ox, however OxError additionally allows completing forks with application errors of type E
in context F
. Such errors cause enclosing scope to end, and any forks that are still running to be cancelled.
Represents a capability to fork asynchronously running computations in a concurrency scope created using supervisedError. This is similar to Ox, however OxError additionally allows completing forks with application errors of type E
in context F
. Such errors cause enclosing scope to end, and any forks that are still running to be cancelled.
Attributes
Attributes
- Supertypes
-
trait Producttrait Equalsclass Throwabletrait Serializableclass Objecttrait Matchableclass AnyShow all
An error mode where errors are represented as an union of E
and T
values. T
should always be different from E
, otherwise errors can't be told apart from successful values. To discern between the two, a class tag for E
is necessary (it must have a distinct run-time representation).
An error mode where errors are represented as an union of E
and T
values. T
should always be different from E
, otherwise errors can't be told apart from successful values. To discern between the two, a class tag for E
is necessary (it must have a distinct run-time representation).
Attributes
- Supertypes
Value members
Concrete methods
Runs partial function in parallel on each element of iterable
for which the partial function is defined. If function is not defined for an element such element is skipped. Using not more than parallelism
forks concurrently.
Runs partial function in parallel on each element of iterable
for which the partial function is defined. If function is not defined for an element such element is skipped. Using not more than parallelism
forks concurrently.
Type parameters
- C
-
type of
iterable
, must be a subtype ofIterable
- I
-
type of elements of
iterable
- O
-
type of elements of result
Value parameters
- iterable
-
collection to transform
- parallelism
-
maximum number of concurrent forks
- pf
-
partial function to apply to those elements of
iterable
for which it is defined
Attributes
- Returns
-
collection of results of applying
pf
to elements ofiterable
for which it is defined. The returned collection is of the same type asiterable
Runs predicate in parallel on each element of iterable
. Elements for which predicate returns true
are returned in the same order as in iterable
. Elements for which predicate returns false
are skipped. Using not more than parallelism
forks concurrently.
Runs predicate in parallel on each element of iterable
. Elements for which predicate returns true
are returned in the same order as in iterable
. Elements for which predicate returns false
are skipped. Using not more than parallelism
forks concurrently.
Type parameters
- C
-
type of
iterable
, must be a subtype ofIterable
- I
-
type of elements in
iterable
Value parameters
- iterable
-
collection to filter
- parallelism
-
maximum number of concurrent forks
- predicate
-
predicate to run on each element of
iterable
Attributes
- Returns
-
filtered collection
Parallelize a foreach operation. Runs the operation on each element of the iterable in parallel. Using not more than parallelism
forks concurrently.
Parallelize a foreach operation. Runs the operation on each element of the iterable in parallel. Using not more than parallelism
forks concurrently.
Type parameters
- C
-
the type of the iterable, must be a subtype of Iterable[I]
- I
-
the type of the elements in the iterable
Value parameters
- iterable
-
the collection to iterate over
- operation
-
the operation to perform on each element
- parallelism
-
the number of threads to use
Attributes
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervised, supervisedError or scoped block completes.
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervised, supervisedError or scoped block completes.
If ran in a supervised scope:
- the fork behaves as a daemon thread
- an exception thrown while evaluating
t
will cause the fork to fail and the enclosing scope to end (cancelling all other running forks) - if the body of the scope completes successfully, and all other user forks complete successfully, the scope will end, cancelling all running forks (including this one, if it's still running). That is, successful completion of this fork isn't required to end the scope.
For alternate behaviors regarding ending the scope, see forkUser, forkError, forkUserError, forkCancellable and forkUnsupervised.
If ran in an unsupervised scope (scoped):
- in case an exception is thrown while evaluating
t
, it will be thrown when calling the returned Fork's.join()
method. - if the main body of the scope completes successfully, while this fork is still running, the fork will be cancelled
Attributes
For each thunk in the given sequence, starts a fork using fork. All forks are guaranteed to complete before the enclosing supervised or scoped block completes.
For each thunk in the given sequence, starts a fork using fork. All forks are guaranteed to complete before the enclosing supervised or scoped block completes.
If ran in a supervised scope, all forks behave as daemon threads (see fork for details).
Attributes
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervised, supervisedError or scoped block completes, and which can be cancelled on-demand.
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervised, supervisedError or scoped block completes, and which can be cancelled on-demand.
In case an exception is thrown while evaluating t
, it will be thrown when calling the returned Fork's .join()
method.
The fork is unsupervised (similarly to forkUnsupervised), hence success or failure isn't signalled to the enclosing scope and doesn't influence the scope's lifecycle.
For alternate behaviors, see fork, forkError, forkUser, forkUserError and forkUnsupervised.
Implementation note: a cancellable fork is created by starting a nested scope in a fork, and then starting a fork there. Hence, it is more expensive than fork, as two virtual threads are started.
Attributes
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervisedError block completes.
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervisedError block completes.
Behaves the same as fork, but additionally allows reporting application errors represented as values of type E
in context F
. An application error causes the enclosing scope to end.
Application errors are values with which forks might successfully complete, but are still considered a value-level representation of an error (as opposed to an exception, which isn't a value which is returned, but is thrown instead). Such errors are reported to the enclosing scope. If the ErrorMode provided when creating the scope using supervisedError classifies a fork return value as an error, the scope ends (cancelling all other running forks).
Attributes
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervised, supervisedError or scoped block completes.
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervised, supervisedError or scoped block completes.
In case an exception is thrown while evaluating t
, it will be thrown when calling the returned Fork's .join()
method.
Success or failure isn't signalled to the enclosing scope, and doesn't influence the scope's lifecycle.
For alternate behaviors, see fork, forkUser and forkCancellable.
Attributes
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervised, supervisedError or scoped block completes.
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervised, supervisedError or scoped block completes.
If ran in a supervised scope:
- the fork behaves as a user-level thread
- an exception thrown while evaluating
t
will cause the enclosing scope to end (cancelling all other running forks) - the scope won't end until the body of the scope, and all other user forks (including this one) complete successfully. That is, successful completion of this fork is required to end the scope.
For alternate behaviors, see fork, forkError, forkUserError, forkCancellable and forkUnsupervised.
If ran in an unsupervised scope (scoped):
- in case an exception is thrown while evaluating
t
, it will be thrown when calling the returned Fork's.join()
method. - if the main body of the scope completes successfully, while this fork is still running, the fork will be cancelled
Attributes
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervisedError block completes.
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosing supervisedError block completes.
Behaves the same as forkUser, but additionally allows reporting application errors represented as values of type E
in context F
, which cause the enclosing scope to end.
Application errors are values with which forks might successfully complete, but are still considered a value-level representation of an error (as opposed to an exception, which isn't a value which is returned, but is thrown instead). Such errors are reported to the enclosing scope. If the ErrorMode provided when creating the scope using supervisedError classifies a fork return value as an error, the scope ends (cancelling all other running forks).
Attributes
Runs parallel transformations on iterable
. Using not more than parallelism
forks concurrently.
Runs parallel transformations on iterable
. Using not more than parallelism
forks concurrently.
Type parameters
- C
-
type of
iterable
, must be a subtype ofIterable
- I
-
type of elements in
iterable
- O
-
type of elements in result
Value parameters
- iterable
-
collection to transform
- parallelism
-
maximum number of concurrent forks
- transform
-
transformation to apply to each element of
iterable
Attributes
- Returns
-
transformed collection of the same type as input one
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
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
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
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
Runs the given computations in parallel. If any fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Runs the given computations in parallel. If any fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
Runs the given computations in parallel. If any fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Runs the given computations in parallel. If any fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
Runs the given computations in parallel. If any fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Runs the given computations in parallel. If any fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
Runs the given computations in parallel. If any fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Runs the given computations in parallel. If any fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
Runs the given computations in parallel. If any fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Runs the given computations in parallel. If any fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Attributes
Runs the given computations in parallel. If any fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Runs the given computations in parallel. If any fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Attributes
Runs the given computations in parallel. If any fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Runs the given computations in parallel. If any fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Attributes
Runs the given computations in parallel. If any fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Runs the given computations in parallel. If any fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Attributes
Runs the given computations in parallel, with at most parallelism
running in parallel at the same time. If any computation fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Runs the given computations in parallel, with at most parallelism
running in parallel at the same time. If any computation fails because of an exception, or if any returns a Left
, other computations are interrupted. Then, the exception is re-thrown, or the Left
error value returned. Each computation must return an Either
, with an error type being a subtype of E
.
Attributes
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
Runs the given computations in parallel, with at most parallelism
running in parallel at the same time. If any computation fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Runs the given computations in parallel, with at most parallelism
running in parallel at the same time. If any computation fails because of an exception, or if any returns an application error, other computations are interrupted. Then, the exception is re-thrown, or the error value returned. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
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
Returns the result of the first computation to complete successfully, or if all fail / return an application error - throws the first exception / returns the first application error. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Returns the result of the first computation to complete successfully, or if all fail / return an application error - throws the first exception / returns the first application error. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
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
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
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
Returns the result of the first computation to complete successfully, or if all fail / return an application error - throws the first exception / returns the first application error. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Returns the result of the first computation to complete successfully, or if all fail / return an application error - throws the first exception / returns the first application error. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
Returns the result of the first computation to complete successfully, or if all fail / return an application error - throws the first exception / returns the first application error. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Returns the result of the first computation to complete successfully, or if all fail / return an application error - throws the first exception / returns the first application error. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
Returns the result of the first computation to complete successfully, or if all fail / return an application error - throws the first exception / returns the first application error. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Returns the result of the first computation to complete successfully, or if all fail / return an application error - throws the first exception / returns the first application error. Application errors must be of type E
in context F
, and each computation must return an F
-wrapped value.
Attributes
Returns the result of the first computation to complete successfully, or if all fail / return a Left
- throws the first exception / returns the first Left
. Each computation must return an Either
, with an error type being a subtype of E
.
Returns the result of the first computation to complete successfully, or if all fail / return a Left
- throws the first exception / returns the first Left
. Each computation must return an Either
, with an error type being a subtype of E
.
Attributes
Returns the result of the first computation to complete successfully, or if all fail / return a Left
- throws the first exception / returns the first Left
. Each computation must return an Either
, with an error type being a subtype of E
.
Returns the result of the first computation to complete successfully, or if all fail / return a Left
- throws the first exception / returns the first Left
. Each computation must return an Either
, with an error type being a subtype of E
.
Attributes
Returns the result of the first computation to complete successfully, or if all fail / return a Left
- throws the first exception / returns the first Left
. Each computation must return an Either
, with an error type being a subtype of E
.
Returns the result of the first computation to complete successfully, or if all fail / return a Left
- throws the first exception / returns the first Left
. Each computation must return an Either
, with an error type being a subtype of E
.
Attributes
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
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
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
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
Repeat evaluating f
until it evaluates to true
.
Repeat evaluating f
until it evaluates to true
.
Attributes
Repeat evaluating f
while it evaluates to true
.
Repeat evaluating f
while it evaluates to true
.
Attributes
Starts a new concurrency scope, which allows starting forks in the given code block f
. Forks can be started using fork, forkUser, forkCancellable and forkUnsupervised. All forks are guaranteed to complete before this scope completes.
Starts a new concurrency scope, which allows starting forks in the given code block f
. Forks can be started using fork, forkUser, forkCancellable and forkUnsupervised. All forks are guaranteed to complete before this scope completes.
Warning: It is advisable to use supervised scopes if possible, as they minimise the chances of an error to go unnoticed. scoped scopes are considered an advanced feature, and should be used with caution.
The scope is ran in unsupervised mode, that is:
- the scope ends once the
f
body completes; this causes any running forks started withinf
to be cancelled - the scope completes (that is, this method returns) only once all forks started by
f
have completed (either successfully, or with an exception) - fork failures aren't handled in any special way, but can be inspected using Fork.join
Forks created using fork, forkUser and forkUnsupervised will behave exactly the same.
Upon successful completion, returns the result of evaluating f
. Upon failure, that is an exception thrown by f
, it is re-thrown.
Attributes
- See also
-
supervised Starts a scope in supervised mode
Starts a new concurrency scope, which allows starting forks in the given code block f
. Forks can be started using fork, forkUser, forkCancellable and forkUnsupervised. All forks are guaranteed to complete before this scope completes.
Starts a new concurrency scope, which allows starting forks in the given code block f
. Forks can be started using fork, forkUser, forkCancellable and forkUnsupervised. All forks are guaranteed to complete before this scope completes.
The scope is ran in supervised mode, that is:
- the scope ends once all user, supervised forks (started using forkUser), including the
f
body, succeed. Forks started using fork (daemon) don't have to complete successfully for the scope to end. - the scope also ends once the first supervised fork (including the
f
main body) fails with an exception - when the scope ends, all running forks are cancelled
- the scope completes (that is, this method returns) only once all forks started by
f
have completed (either successfully, or with an exception)
Upon successful completion, returns the result of evaluating f
. Upon failure, the exception that caused the scope to end is re-thrown (regardless if the exception was thrown from the main body, or from a fork). Any other exceptions that occur when completing the scope are added as suppressed.
Attributes
- See also
-
scoped Starts a scope in unsupervised mode
supervisedError Starts a scope in supervised mode, with the additional ability to report application errors
Starts a new concurrency scope, which allows starting forks in the given code block f
. Forks can be started using fork, forkError, forkUser, forkUserError, forkCancellable and forkUnsupervised. All forks are guaranteed to complete before this scope completes.
Starts a new concurrency scope, which allows starting forks in the given code block f
. Forks can be started using fork, forkError, forkUser, forkUserError, forkCancellable and forkUnsupervised. All forks are guaranteed to complete before this scope completes.
Behaves the same as supervised, but additionally allows reporting application errors represented as values of type E
in context F
. An application error causes the enclosing scope to end.
Attributes
- See also
-
forkError On details how to use application errors.
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 thanduration
.
Result of the computation t
if it took less than duration
, and Left(timeoutValue)
otherwise.
Result of the computation t
if it took less than duration
, and Left(timeoutValue)
otherwise.
Attributes
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
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.