Package org.bsc.async

Class AsyncGenerator.BaseCancellable<E>

java.lang.Object
org.bsc.async.AsyncGenerator.Base<E>
org.bsc.async.AsyncGenerator.BaseCancellable<E>
All Implemented Interfaces:
AutoCloseable, Iterable<E>, AsyncGenerator<E>, AsyncGenerator.Cancellable<E>, AsyncGenerator.IsCancellable
Direct Known Subclasses:
AsyncGenerator.WithEmbed, AsyncGenerator.WithResult, AsyncGeneratorQueue.Generator
Enclosing interface:
AsyncGenerator<E>

public abstract static class AsyncGenerator.BaseCancellable<E> extends AsyncGenerator.Base<E> implements AsyncGenerator.Cancellable<E>
  • Constructor Details

    • BaseCancellable

      public BaseCancellable()
  • Method Details

    • isCancelled

      public boolean isCancelled()
      Description copied from interface: AsyncGenerator.IsCancellable
      Checks if the asynchronous generation has been cancelled.

      The default implementation always returns false. Implementations that support cancellation should override this method.

      Specified by:
      isCancelled in interface AsyncGenerator.IsCancellable
      Returns:
      true if the generator has been cancelled, false otherwise.
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      Requests cancellation of the generator.

      This method sets the cancelled flag and closes the executor to release resources. If mayInterruptIfRunning is true, the executor will be shut down immediately, interrupting any running tasks.

      Specified by:
      cancel in interface AsyncGenerator.IsCancellable
      Parameters:
      mayInterruptIfRunning - if true, interrupt running tasks
      Returns:
      true if cancellation was successful, false if already cancelled