class Opal::Async::Worker

Overview

Background asynchronous worker fiber inspired by Python Textual Workers. Executes long-running tasks concurrently without blocking terminal rendering or freezing input.

Defined in:

opal/async/worker.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String = "worker", &work : Worker -> String | Int32 | Int64 | Float64 | Bool | Nil) #

[View source]

Instance Method Detail

def cancel : self #

Requests worker cancellation


[View source]
def cancelled? : Bool #

[View source]
def error : Exception | Nil #

[View source]
def name : String #

[View source]
def on_complete(&block : -> Nil) : self #

[View source]
def on_error(&block : Exception -> Nil) : self #

[View source]
def on_progress(&block : Float64 -> Nil) : self #

[View source]
def progress : Float64 #

[View source]
def report_progress(p : Float64) : Nil #

Called by the worker block to report incremental completion percentage (0.0 to 1.0)


[View source]
def result : String | Int32 | Int64 | Float64 | Bool | Nil #

[View source]
def start : self #

Spawns background execution fiber


[View source]
def state : WorkerState #

[View source]