Packages

p

net.gfxmonk

capsul

package capsul

See also

Capsul

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. capsul
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class Capsul [T] extends AnyRef

    An encapsulation for thread-safe state.

    An encapsulation for thread-safe state.

    Methods are named <dispatch><operation><mode>

    Dispatch types:

    • send: Enqueue an action, returning Future[Unit]. Once the future is resolved, the action has been accepted by the worker, but not necessarily performed.
    • (none): Perform an action, returning a StagedFuture[T].

    Operations:

    • mutate: accepts a function of type Ref[T] => R, returns R
    • transform: accepts a function of type T => T, returns Unit
    • set: accepts a new value of type T, returns Unit
    • access: accepts a function of type T => R, returns R. The function is executed sequentually with other tasks, so it's safe to mutate T. If you simply want to get the current vaue without blocking other tasks, use current.

    Modes:

    Modes control when the state will accept more work. Each state will accept up to bufLen items immediately, and will run the functions sequentually.

    For asynchronous modes, subsequent tasks will still be run immediately after the function completes, but the task won't be considered done (for the purposes of accepting more tasks) until the future is resolved.

    This means that you must be careful with mutate actions or with mutable state objects - you may mutate the state during the execution of the function, but you may not do so asynchronously (e.g. after your future completes)

    • (empty): Synchronous. The task is completed as soon as it returns.
    • async: async (Future). The work returns a Future[T], and the next task may begin immediately. This task continues to occupy a slot in this state's queue until the future completes.
    • staged: async (StagedFuture). The work returns a StagedFuture[T], and the next task may begin immediately. This task continues to occupy a slot in this state's queue until the StagedFuture is accepted.
  2. trait EnqueueableTask extends AnyRef
  3. class Ref [T] extends AnyRef

    A wrapper for getting / setting state

  4. class RingItem [T >: Null <: AnyRef] extends AnyRef
  5. class SequentialExecutor extends AnyRef
  6. trait StagedFuture [T] extends Future[T]

    A staged future represents both asynchronous acceptance and asynchronous fulfilment of a piece of work.

    A staged future represents both asynchronous acceptance and asynchronous fulfilment of a piece of work.

    By explicitly representing asynchronous acceptance, consumers can implement backpressure without resorting to synchronous blocking.

    It's conceptually just a Future[Future[T]], where the outer future is resolved once the receiver has accepted the work, and the inner future is resolved once the work is actually complete. For convenience, it also implements Future[T] so you can wait for the final result easily when necessary.

    The only additional methods on top of Future are:

  7. trait UnitOfWork [A] extends EnqueueableTask

Inherited from AnyRef

Inherited from Any

Ungrouped