CancelableF

object CancelableF
Companion
class
class Object
trait Matchable
class Any

Type members

Classlikes

trait Empty[F[_]] extends CancelableF[F] with IsDummy[F]

Interface for cancelables that are empty or already canceled.

Interface for cancelables that are empty or already canceled.

trait IsDummy[F[_]]

Marker for cancelables that are dummies that can be ignored.

Marker for cancelables that are dummies that can be ignored.

Value members

Concrete methods

def apply[F[_]](token: F[Unit])(F: Sync[F]): F[CancelableF[F]]

Given a token that does not guarantee idempotency, wraps it in a CancelableF value that guarantees the given token will execute only once.

Given a token that does not guarantee idempotency, wraps it in a CancelableF value that guarantees the given token will execute only once.

def cancelAll[F[_]](seq: CancelableF[F]*)(F: Sync[F]): CancelToken[F]

Given a collection of cancelables, creates a token that on evaluation will cancel them all.

Given a collection of cancelables, creates a token that on evaluation will cancel them all.

This function collects non-fatal exceptions and throws them all at the end as a composite, in a platform specific way:

  • for the JVM "Suppressed Exceptions" are used
  • for JS they are wrapped in a CompositeException
def cancelAllTokens[F[_]](seq: CancelToken[F]*)(F: Sync[F]): CancelToken[F]

Given a collection of cancel tokens, creates a token that on evaluation will cancel them all.

Given a collection of cancel tokens, creates a token that on evaluation will cancel them all.

This function collects non-fatal exceptions and throws them all at the end as a composite, in a platform specific way:

  • for the JVM "Suppressed Exceptions" are used
  • for JS they are wrapped in a CompositeException
def collection[F[_]](refs: CancelableF[F]*)(F: Sync[F]): CancelableF[F]

Builds a CancelableF reference from a sequence, cancelling everything when cancel gets evaluated.

Builds a CancelableF reference from a sequence, cancelling everything when cancel gets evaluated.

def empty[F[_]](F: Applicative[F]): CancelableF[F]

Returns a dummy CancelableF that doesn't do anything.

Returns a dummy CancelableF that doesn't do anything.

@UnsafeBecauseImpure
def unsafeApply[F[_]](token: F[Unit])(F: Sync[F]): CancelableF[F]

Unsafe version of apply.

Unsafe version of apply.

This function is unsafe because creating the returned BooleanCancelableF allocates internal shared mutable state, thus breaking referential transparency, which can catch users by surprise.

def wrap[F[_]](token: CancelToken[F]): CancelableF[F]

Wraps a cancellation token into a CancelableF instance.

Wraps a cancellation token into a CancelableF instance.

Compared with apply the returned value does not guarantee idempotency.

N.B. the returned result is as pure as the wrapped result. Since we aren't allocating mutable internal state for creating this value, we don't need to return the value in F[_], like in apply.