class

Termisu::FFI::Context

Inherits Reference < Object

Constants

POLL_CANCELLATION_INTERVAL = 1.millisecond

Bound the time an FFI poll waits before observing cross-thread shutdown. Crystal channels are scheduler-local in supported non-preview_mt builds, while atomics and OS sleeps work from arbitrary host threads.

Constructors

new(sync_updates : Bool)
Source

Instance methods

close
Source
operations_in_flight?

Exposed for lifecycle coordination and focused concurrency assertions.

Source
poll_event(timeout_ms : Int32) : Event::Any | Nil

Polls non-blockingly between short OS sleeps so close can cancel an indefinite (or very long) wait before draining operation leases. Avoiding scheduler waits is required because the C ABI may run on a foreign thread. The ownership lease remains held until close completes all cleanup below.

Source
termisu
Source
with_operation

Runs one FFI operation while preventing close from crossing its lifetime. The second closing check closes the race between the first check and the counter increment: such a caller backs out without touching Termisu.

Source