package async
- Alphabetic
- By Inheritance
- async
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
final
class
Promise[F[_], A] extends AnyRef
A purely functional synchronisation primitive.
A purely functional synchronisation primitive.
When created, a
Promiseis empty. It can then be completed exactly once, and never be made empty again.geton an emptyPromisewill block until thePromiseis completed.geton a completedPromisewill always immediately return its content.complete(a)on an emptyPromisewill set it toa, and notify any and all readers currently blocked on a call toget.complete(a)on aPromisethat's already been completed will not modify its content, and result in a failedF.Albeit simple,
Promisecan be used in conjunction with Ref to build complex concurrent behaviour and data structures like queues and semaphores.Finally, the blocking mentioned above is semantic only, no actual threads are blocked by the implementation.
-
final
class
Ref[F[_], A] extends AnyRef
An asynchronous, concurrent mutable reference.
An asynchronous, concurrent mutable reference.
Provides safe concurrent access and modification of its content, but no functionality for synchronisation, which is instead handled by Promise. For this reason, a
Refis always initialised to a value.The implementation is nonblocking and lightweight, consisting essentially of a purely functional wrapper over an
AtomicReference
Value Members
-
def
boundedQueue[F[_], A](maxSize: Int)(implicit arg0: Effect[F], ec: ExecutionContext): F[Queue[F, A]]
Creates a bounded asynchronous queue.
Creates a bounded asynchronous queue. Calls to
enqueue1will wait until the queue's size is less thanmaxSize. See mutable.Queue for more documentation. -
def
circularBuffer[F[_], A](maxSize: Int)(implicit F: Effect[F], ec: ExecutionContext): F[Queue[F, A]]
Creates a queue that functions as a circular buffer.
Creates a queue that functions as a circular buffer. Up to
sizeelements of typeAwill accumulate on the queue and then it will begin overwriting the oldest elements. Thus an enqueue process will never wait.- maxSize
The size of the circular buffer (must be > 0)
-
def
fork[F[_], A](f: F[A])(implicit F: Effect[F], ec: ExecutionContext): F[Unit]
Begins asynchronous evaluation of
fwhen the returnedF[Unit]is bound.Begins asynchronous evaluation of
fwhen the returnedF[Unit]is bound. Likestartbut is more efficient. -
def
hold[F[_], A](initial: A, source: Stream[F, A])(implicit F: Effect[F], ec: ExecutionContext): Stream[F, Signal[F, A]]
Converts a discrete stream to a signal.
Converts a discrete stream to a signal. Returns a single-element stream.
Resulting signal is initially
initial, and is updated with latest value produced bysource. Ifsourceis empty, the resulting signal will always beinitial.- source
discrete stream publishing values to this signal
-
def
holdOption[F[_], A](source: Stream[F, A])(implicit arg0: Effect[F], ec: ExecutionContext): Stream[F, Signal[F, Option[A]]]
Defined as
hold(None, source.map(Some(_))) -
def
parallelSequence[F[_], G[_], A](fga: F[G[A]])(implicit F: Traverse[F], G: Effect[G], ec: ExecutionContext): G[F[A]]
Like
sequencebut eachG[A]is evaluated in parallel. -
def
parallelTraverse[F[_], G[_], A, B](fa: F[A])(f: (A) ⇒ G[B])(implicit F: Traverse[F], G: Effect[G], ec: ExecutionContext): G[F[B]]
Like
traversebut eachG[B]computed from anAis evaluated in parallel. -
def
promise[F[_], A](implicit arg0: Effect[F], ec: ExecutionContext): F[Promise[F, A]]
Creates an empty
Promise[F, A] -
def
refOf[F[_], A](a: A)(implicit arg0: Sync[F]): F[Ref[F, A]]
Creates an initialized
SyncRef[F,A]. -
def
semaphore[F[_]](initialCount: Long)(implicit arg0: Effect[F], ec: ExecutionContext): F[Semaphore[F]]
Creates a
mutable.Semaphore, initialized to the given count. -
def
signalOf[F[_], A](initialValue: A)(implicit arg0: Effect[F], ec: ExecutionContext): F[Signal[F, A]]
Creates a new continuous signal which may be controlled asynchronously, and immediately sets the value to
initialValue. -
def
start[F[_], A](f: F[A])(implicit F: Effect[F], ec: ExecutionContext): F[F[A]]
Begins asynchronous evaluation of
fwhen the returnedF[F[A]]is bound.Begins asynchronous evaluation of
fwhen the returnedF[F[A]]is bound. The innerF[A]will block until the result is available. -
def
synchronousQueue[F[_], A](implicit F: Effect[F], ec: ExecutionContext): F[Queue[F, A]]
Creates a synchronous queue, which always has size 0.
Creates a synchronous queue, which always has size 0. Any calls to
enqueue1block until there is an offsetting call todequeue1. Any calls todequeue1block until there is an offsetting call toenqueue1. -
def
topic[F[_], A](initial: A)(implicit arg0: Effect[F], ec: ExecutionContext): F[Topic[F, A]]
Creates an asynchronous topic, which distributes each published
Ato an arbitrary number of subscribers.Creates an asynchronous topic, which distributes each published
Ato an arbitrary number of subscribers. Each subscriber is guaranteed to receive at least the initialAor last value published by any publisher. -
def
unboundedQueue[F[_], A](implicit arg0: Effect[F], ec: ExecutionContext): F[Queue[F, A]]
Creates an unbounded asynchronous queue.
Creates an unbounded asynchronous queue. See mutable.Queue for more documentation.
-
def
unsafeRunAsync[F[_], A](fa: F[A])(f: (Either[Throwable, A]) ⇒ IO[Unit])(implicit F: Effect[F], ec: ExecutionContext): Unit
Like
unsafeRunSyncbut execution is shifted to the supplied execution context.Like
unsafeRunSyncbut execution is shifted to the supplied execution context. This method returns immediately after submitting execution to the execution context. - object Promise
- object Ref