class Termisu::Event::Poller::Poll

Defined in:

termisu/event/poller/poll.cr

Constant Summary

Log = Termisu::Logs::Event

Constructors

Instance Method Summary

Instance methods inherited from class Termisu::Event::Poller

add_timer(interval : Time::Span, repeating : Bool = true) : TimerHandle add_timer, close : Nil close, modify_timer(handle : TimerHandle, interval : Time::Span) : Nil modify_timer, register_fd(fd : Int32, events : FDEvents) : Nil register_fd, remove_timer(handle : TimerHandle) : Nil remove_timer, unregister_fd(fd : Int32) : Nil unregister_fd, wait(timeout : Time::Span) : PollResult | Nil
wait : PollResult | Nil
wait

Constructor methods inherited from class Termisu::Event::Poller

create : Poller create

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def add_timer(interval : Time::Span, repeating : Bool = true) : TimerHandle #
Description copied from class Termisu::Event::Poller

Creates a new timer with the specified interval.

  • interval - Time between timer expirations
  • repeating - If true, timer auto-rearms; if false, fires once

Returns a TimerHandle for later modification or removal. Raises IO::Error on system error.


[View source]
def close : Nil #
Description copied from class Termisu::Event::Poller

Releases all resources held by the poller.

Closes internal file descriptors and clears timer state. Safe to call multiple times (idempotent).


[View source]
def modify_timer(handle : TimerHandle, interval : Time::Span) : Nil #
Description copied from class Termisu::Event::Poller

Modifies an existing timer's interval.

  • handle - Timer to modify
  • interval - New interval

Raises ArgumentError if handle is invalid.


[View source]
def register_fd(fd : Int32, events : FDEvents) : Nil #
Description copied from class Termisu::Event::Poller

Registers a file descriptor for event monitoring.

  • fd - File descriptor to monitor
  • events - Event types to monitor (read, write, error)

Raises IO::Error on system error.


[View source]
def remove_timer(handle : TimerHandle) : Nil #
Description copied from class Termisu::Event::Poller

Removes a timer.

Safe to call with already-removed handle (no-op).


[View source]
def unregister_fd(fd : Int32) : Nil #
Description copied from class Termisu::Event::Poller

Unregisters a file descriptor from event monitoring.

Safe to call with unregistered fd (no-op).


[View source]
def wait(timeout : Time::Span) : PollResult | Nil #
Description copied from class Termisu::Event::Poller

Waits for an event with timeout.

Returns nil if timeout expires without an event. Handles EINTR internally by retrying.


[View source]
def wait : PollResult | Nil #
Description copied from class Termisu::Event::Poller

Waits indefinitely for an event.

Blocks until an event occurs. Returns nil if the poller is closed or interrupted in a way that signals shutdown.

Handles EINTR internally by retrying.


[View source]