Teek API Documentation

Context object passed to the worker block inside the Ractor. Provides methods for yielding results, sending/receiving messages, and responding to pause/stop signals.

Inherits: Object

Instance Methods

check_message

Non-blocking check for a message from the main thread. Handles built-in control messages (:pause, :resume, :stop) automatically; :stop raises StopIteration.

Returns Object, nil — the message, or nil if none pending

check_pause

Block while paused, returning immediately if not paused. Call this periodically in long-running loops to honor pause requests.

initialize(output_port, msg_queue)

Returns TaskContext — a new instance of TaskContext

@api private

send_message(msg)

Send a custom message back to the main thread. Arrives in the BackgroundWork#on_message callback.

Parameters
  • msg Object — any Ractor-shareable value

wait_message

Blocking wait for the next message from the main thread. Handles control messages automatically.

Returns Object — the message

yield(value)

Send a result to the main thread. Blocks while paused. The value arrives in the BackgroundWork#on_progress callback.

Parameters
  • value Object — any Ractor-shareable value