class
Termisu::FFI::Context
- Termisu::FFI::Context
- Reference
- Object
Defined in:
termisu/ffi/context.crConstant Summary
-
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
Instance Method Summary
- #close : Nil
-
#operations_in_flight? : Bool
Exposed for lifecycle coordination and focused concurrency assertions.
-
#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.
- #termisu : Termisu
-
#with_operation(& : self -> T) : T | Nil forall T
Runs one FFI operation while preventing close from crossing its lifetime.
Constructor Detail
Instance Method Detail
Exposed for lifecycle coordination and focused concurrency assertions.
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.
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.