package concurrent
- Alphabetic
- Public
- All
Type Members
-
final
case class
Actor[A](handler: (A) ⇒ Unit, onError: (Throwable) ⇒ Unit = ActorUtils.rethrowError)(implicit strategy: Strategy) extends Product with Serializable
Processes messages of type
A
, one at a time.Processes messages of type
A
, one at a time. Messages are submitted to the actor with the method!
. Processing is typically performed asynchronously, this is controlled by the providedstrategy
.Memory consistency guarantee: when each message is processed by the
handler
, any memory that it mutates is guaranteed to be visible by thehandler
when it processes the next message, even if thestrategy
runs the invocations ofhandler
on separate threads. This is achieved because theActor
reads a volatile memory location before entering its event loop, and writes to the same location before suspending.Implementation based on non-intrusive MPSC node-based queue, described by Dmitriy Vyukov: http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue
- A
The type of messages accepted by this actor.
- handler
The message handler
- onError
Exception handler, called if the message handler throws any
Throwable
.- strategy
Execution strategy, for example, a strategy that is backed by an
ExecutorService
- See also
scalaz.concurrent.Promise for a use case.
- trait ActorFunctions extends AnyRef
- sealed abstract class ActorInstances extends AnyRef
- trait Atomic[A] extends AnyRef
- trait Atomics extends AnyRef
- trait BooleanLatch extends AnyRef
- sealed trait Chan[A] extends AnyRef
- trait Concurrents extends ActorFunctions with PromiseFunctions
-
sealed abstract
class
Future[+A] extends AnyRef
Future
is a trampolined computation producing anA
that may include asynchronous steps.Future
is a trampolined computation producing anA
that may include asynchronous steps. LikeTrampoline
, arbitrary monadic expressions involvingmap
andflatMap
are guaranteed to use constant stack space. But in addition, one may construct aFuture
from an asynchronous computation, represented as a function,listen: (A => Unit) => Unit
, which registers a callback that will be invoked when the result becomes available. This makesFuture
useful as a concurrency primitive and as a control structure for wrapping callback-based APIs with a more straightforward, monadic API.Unlike the
Future
implementation in scala 2.10,map
andflatMap
do NOT spawn new tasks and do not require an implicitExecutionContext
. Instead,map
andflatMap
merely add to the current (trampolined) continuation that will be run by the 'current' thread, unless explicitly forked viaFuture.fork
orFuture.apply
. This means thatFuture
achieves much better thread reuse than the 2.10 implementation and avoids needless thread pool submit cycles.Future
also differs from the scala 2.10Future
type in that it does not necessarily represent a _running_ computation. Instead, we reintroduce nondeterminism _explicitly_ using the functions of thescalaz.Nondeterminism
interface. This simplifies our implementation and makes code easier to reason about, since the order of effects and the points of nondeterminism are made fully explicit and do not depend on Scala's evaluation order.IMPORTANT NOTE:
Future
does not include any error handling and should generally only be used as a building block by library writers who want to build onFuture
's capabilities but wish to design their own error handling strategy. Seescalaz.concurrent.Task
for a type that extendsFuture
with proper error handling -- it is merely a wrapper forFuture[Throwable \/ A]
with a number of additional convenience functions. - sealed trait MVar[A] extends AnyRef
- trait MVarFunctions extends AnyRef
- sealed trait PhasedLatch extends AnyRef
- trait PhasedLatches extends AnyRef
- trait Run[F] extends AnyRef
-
trait
Strategy extends AnyRef
Evaluate an expression in some specific manner.
Evaluate an expression in some specific manner. A typical strategy will schedule asynchronous evaluation and return a function that, when called, will block until the result is ready.
Memory consistency effects: Actions in a thread prior to the submission of
a
to theStrategy
happen-before any actions taken bya
, which in turn happen-before the result is retrieved via returned function. - trait Strategys extends StrategysLow
- trait StrategysLow extends AnyRef
-
class
Task[+A] extends AnyRef
Task[A]
wraps ascalaz.concurrent.Future[Throwable \/ A]
, with some convenience functions for handling exceptions.Task[A]
wraps ascalaz.concurrent.Future[Throwable \/ A]
, with some convenience functions for handling exceptions. ItsMonad
andNondeterminism
instances are derived from Future.Task
(andFuture
) differ in several key ways fromscalaz.concurrent.Promise
and theFuture
implementation in Scala 2.10 , and have a number of advantages. See the documentation for scalaz.concurrent.Future for more information.Task
is exception-safe when constructed using the primitives in the companion object, but when calling the constructor, you are responsible for ensuring the exception safety of the providedFuture
. -
trait
TaskApp extends AnyRef
Safe
App
trait that runs ascalaz.concurrent.Task
action.Safe
App
trait that runs ascalaz.concurrent.Task
action.Clients should implement
run
,runl
, orrunc
. - trait Timeout extends AnyRef
- case class Timer(timeoutTickMs: Int = 100, workerName: String = "TimeoutContextWorker") extends Product with Serializable
-
sealed
trait
Promise[A] extends AnyRef
- Annotations
- @deprecated
- Deprecated
(Since version 7.1) use
Future
or other concurrency abstractions
-
trait
PromiseFunctions extends AnyRef
- Annotations
- @deprecated
- Deprecated
(Since version 7.1) use
Future
or other concurrency abstractions
-
sealed abstract
class
PromiseInstances extends AnyRef
- Annotations
- @deprecated
- Deprecated
(Since version 7.1) use
Future
or other concurrency abstractions
Value Members
- object Actor extends ActorInstances with ActorFunctions with Serializable
- object Atomic extends Atomics
- object BooleanLatch
- object Chan
- object Concurrent extends Concurrents
- object Future
- object MVar extends MVarFunctions
- object PhasedLatch extends PhasedLatches
- object Run
- object Strategy extends Strategys
- object Task
- object Timeout extends Timeout
- object Timer extends Serializable
Deprecated Value Members
-
object
Promise extends PromiseInstances with PromiseFunctions
- Annotations
- @deprecated
- Deprecated
(Since version 7.1) use
Future
or other concurrency abstractions