Package

fs2

async

Permalink

package async

Provides utilities for asynchronous computations.

Source
async.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. async
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final class Promise[F[_], A] extends AnyRef

    Permalink

    A purely functional synchronisation primitive.

    A purely functional synchronisation primitive.

    When created, a Promise is empty. It can then be completed exactly once, and never be made empty again.

    get on an empty Promise will block until the Promise is completed. get on a completed Promise will always immediately return its content.

    complete(a) on an empty Promise will set it to a, and notify any and all readers currently blocked on a call to get. complete(a) on a Promise that's already been completed will not modify its content, and result in a failed F.

    Albeit simple, Promise can 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.

  2. final class Ref[F[_], A] extends AnyRef

    Permalink

    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 Ref is always initialised to a value.

    The implementation is nonblocking and lightweight, consisting essentially of a purely functional wrapper over an AtomicReference

Value Members

  1. object Promise

    Permalink
  2. object Ref

    Permalink
  3. def boundedQueue[F[_], A](maxSize: Int)(implicit arg0: Effect[F], ec: ExecutionContext): F[Queue[F, A]]

    Permalink

    Creates a bounded asynchronous queue.

    Creates a bounded asynchronous queue. Calls to enqueue1 will wait until the queue's size is less than maxSize. See mutable.Queue for more documentation.

  4. def circularBuffer[F[_], A](maxSize: Int)(implicit F: Effect[F], ec: ExecutionContext): F[Queue[F, A]]

    Permalink

    Creates a queue that functions as a circular buffer.

    Creates a queue that functions as a circular buffer. Up to size elements of type A will 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)

  5. def fork[F[_], A](f: F[A])(implicit F: Effect[F], ec: ExecutionContext): F[Unit]

    Permalink

    Begins asynchronous evaluation of f when the returned F[Unit] is bound.

    Begins asynchronous evaluation of f when the returned F[Unit] is bound. Like start but is more efficient.

  6. def hold[F[_], A](initial: A, source: Stream[F, A])(implicit F: Effect[F], ec: ExecutionContext): Stream[F, Signal[F, A]]

    Permalink

    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 by source. If source is empty, the resulting signal will always be initial.

    source

    discrete stream publishing values to this signal

  7. def holdOption[F[_], A](source: Stream[F, A])(implicit arg0: Effect[F], ec: ExecutionContext): Stream[F, Signal[F, Option[A]]]

    Permalink

    Defined as hold(None, source.map(Some(_)))

  8. package immutable

    Permalink

    Provides types which allow asynchronous reading (but not writing).

  9. package mutable

    Permalink

    Provides types which allow asynchronous reading and writing.

  10. def parallelSequence[F[_], G[_], A](fga: F[G[A]])(implicit F: Traverse[F], G: Effect[G], ec: ExecutionContext): G[F[A]]

    Permalink

    Like sequence but each G[A] is evaluated in parallel.

  11. 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]]

    Permalink

    Like traverse but each G[B] computed from an A is evaluated in parallel.

  12. def promise[F[_], A](implicit arg0: Effect[F], ec: ExecutionContext): F[Promise[F, A]]

    Permalink

    Creates an empty Promise[F, A]

  13. def refOf[F[_], A](a: A)(implicit arg0: Sync[F]): F[Ref[F, A]]

    Permalink

    Creates an initialized SyncRef[F,A].

  14. def semaphore[F[_]](initialCount: Long)(implicit arg0: Effect[F], ec: ExecutionContext): F[Semaphore[F]]

    Permalink

    Creates a mutable.Semaphore, initialized to the given count.

  15. def signalOf[F[_], A](initialValue: A)(implicit arg0: Effect[F], ec: ExecutionContext): F[Signal[F, A]]

    Permalink

    Creates a new continuous signal which may be controlled asynchronously, and immediately sets the value to initialValue.

  16. def start[F[_], A](f: F[A])(implicit F: Effect[F], ec: ExecutionContext): F[F[A]]

    Permalink

    Begins asynchronous evaluation of f when the returned F[F[A]] is bound.

    Begins asynchronous evaluation of f when the returned F[F[A]] is bound. The inner F[A] will block until the result is available.

  17. def synchronousQueue[F[_], A](implicit F: Effect[F], ec: ExecutionContext): F[Queue[F, A]]

    Permalink

    Creates a synchronous queue, which always has size 0.

    Creates a synchronous queue, which always has size 0. Any calls to enqueue1 block until there is an offsetting call to dequeue1. Any calls to dequeue1 block until there is an offsetting call to enqueue1.

  18. def topic[F[_], A](initial: A)(implicit arg0: Effect[F], ec: ExecutionContext): F[Topic[F, A]]

    Permalink

    Creates an asynchronous topic, which distributes each published A to an arbitrary number of subscribers.

    Creates an asynchronous topic, which distributes each published A to an arbitrary number of subscribers. Each subscriber is guaranteed to receive at least the initial A or last value published by any publisher.

  19. def unboundedQueue[F[_], A](implicit arg0: Effect[F], ec: ExecutionContext): F[Queue[F, A]]

    Permalink

    Creates an unbounded asynchronous queue.

    Creates an unbounded asynchronous queue. See mutable.Queue for more documentation.

  20. def unsafeRunAsync[F[_], A](fa: F[A])(f: (Either[Throwable, A]) β‡’ IO[Unit])(implicit F: Effect[F], ec: ExecutionContext): Unit

    Permalink

    Like unsafeRunSync but execution is shifted to the supplied execution context.

    Like unsafeRunSync but execution is shifted to the supplied execution context. This method returns immediately after submitting execution to the execution context.

Inherited from AnyRef

Inherited from Any

Ungrouped