class Async::Task
def stop(later = false)
-
(void)
-
def stop(later = false) if self.stopped? # If we already stopped this task... don't try to stop it again: return end if self.running? if self.current? if later @reactor << Stop::Later.new(self) else raise Stop, "Stopping current task!" end elsif @fiber&.alive? begin @fiber.resume(Stop.new) rescue FiberError @reactor << Stop::Later.new(self) end end else # We are not running, but children might be, so transition directly into stopped state: stop! end end