NAME

Hypersonic::Event::EventPorts - Event Ports backend for Solaris/illumos

SYNOPSIS

use Hypersonic::Event;

my $backend = Hypersonic::Event->backend('event_ports');
# $backend is 'Hypersonic::Event::EventPorts'

DESCRIPTION

Hypersonic::Event::EventPorts is the event ports-based event backend for Hypersonic on Solaris 10+ and illumos-based systems (SmartOS, OmniOS, etc).

Event ports are the modern, high-performance event notification mechanism on Solaris, replacing the older /dev/poll interface. They provide O(1) event notification similar to Linux's epoll and BSD's kqueue.

KEY CHARACTERISTICS

  • One-shot semantics - must re-associate after each event

  • Can monitor file descriptors, timers, and other sources

  • Provides event source information in results

  • port_getn() can retrieve multiple events at once

ONE-SHOT BEHAVIOR

Unlike epoll (with EPOLLET) or kqueue, event ports are inherently one-shot. After an event is delivered, the file descriptor is automatically dissociated from the port. You must call port_associate() again to receive more events.

This is handled automatically by gen_get_fd() which re-associates fds.

METHODS

name

my $name = Hypersonic::Event::EventPorts->name;  # 'event_ports'

Returns the backend name.

available

if (Hypersonic::Event::EventPorts->available) { ... }

Returns true only on Solaris/illumos systems with event ports support.

includes

Returns the C #include directives needed for event ports.

defines

Returns the C #define directives for event ports configuration.

event_struct

my $struct = Hypersonic::Event::EventPorts->event_struct;  # 'port_event_t'

Returns the C struct name used for the events array.

gen_create($builder, $listen_fd_var)

Generates C code to create an event port and associate the listen socket.

gen_add($builder, $loop_var, $fd_var)

Generates C code to associate a file descriptor with the event port.

gen_del($builder, $loop_var, $fd_var)

Generates C code to dissociate a file descriptor from the event port.

gen_wait($builder, $loop_var, $events_var, $count_var, $timeout_var)

Generates C code to wait for events using port_getn().

gen_get_fd($builder, $events_var, $index_var, $fd_var)

Generates C code to extract the file descriptor from an event and re-associate it for future events.

COMPARISON WITH OTHER BACKENDS

Backend       Platform    Semantics    Performance
-------       --------    ---------    -----------
epoll         Linux       Level/Edge   O(1)
kqueue        BSD/macOS   Level/Edge   O(1)
event_ports   Solaris     One-shot     O(1)
io_uring      Linux 5.1+  Completion   O(1) + batching
poll          POSIX       Level        O(n)
select        All         Level        O(n)

AVAILABILITY

Solaris 10 and later, illumos distributions (SmartOS, OmniOS, OpenIndiana).

SEE ALSO

Hypersonic::Event, Hypersonic::Event::Role, Hypersonic::Event::Poll

For more information on event ports: https://docs.oracle.com/cd/E19253-01/816-5168/port-create-3c/index.html

AUTHOR

LNATION <email@lnation.org>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.