monifu.concurrent

cancelables

package cancelables

Cancelables represent asynchronous units of work or other things scheduled for execution and whose execution can be canceled.

One use-case is the scheduling done by monifu.concurrent.Scheduler, in which the scheduling methods return a Cancelable, allowing the canceling of the scheduling.

Example:

val s = ConcurrentScheduler()
val task = s.scheduleRepeated(10.seconds, 50.seconds, {
  println("Hello")
})

// later, cancels the scheduling ...
task.cancel()
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. cancelables
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. trait BooleanCancelable extends Cancelable

    Represents a Cancelable that can queried for the canceled status.

  2. trait CompositeCancelable extends BooleanCancelable

    Represents a composite of multiple cancelables.

    Represents a composite of multiple cancelables. In case it is canceled, all contained cancelables will be canceled too, e.g...

    val s = CompositeCancelable()
    
    s += c1
    s += c2
    s += c3
    
    // c1, c2, c3 will also be canceled
    s.cancel()

    Additionally, once canceled, on appending of new cancelable references, those references will automatically get canceled too:

    val s = CompositeCancelable()
    s.cancel()
    
    // c1 gets canceled, because s is already canceled
    s += c1
    // c2 gets canceled, because s is already canceled
    s += c2

    Adding and removing references from this composite is thread-safe.

  3. final class MultiAssignmentCancelable extends BooleanCancelable

    Represents a monifu.concurrent.Cancelable whose underlying cancelable reference can be swapped for another.

    Represents a monifu.concurrent.Cancelable whose underlying cancelable reference can be swapped for another.

    Example:

    val s = MultiAssignmentCancelable()
    s() = c1 // sets the underlying cancelable to c1
    s() = c2 // swaps the underlying cancelable to c2
    
    s.cancel() // also cancels c2
    
    s() = c3 // also cancels c3, because s is already canceled
  4. final class RefCountCancelable extends BooleanCancelable

    Represents a Cancelable that only executes the canceling logic when all dependent cancelable objects have been canceled.

    Represents a Cancelable that only executes the canceling logic when all dependent cancelable objects have been canceled.

    After all dependent cancelables have been canceled, onCancel gets called.

  5. final class SingleAssignmentCancelable extends BooleanCancelable

    Represents a monifu.concurrent.Cancelable that can be assigned only once to another cancelable reference.

    Represents a monifu.concurrent.Cancelable that can be assigned only once to another cancelable reference.

    Similar to monifu.concurrent.cancelables.MultiAssignmentCancelable, except that in case of multi-assignment, it throws a java.lang.IllegalStateException.

    If the assignment happens after this cancelable has been canceled, then on assignment the reference will get canceled too.

    Useful in case you need a forward reference.

Inherited from AnyRef

Inherited from Any

Ungrouped