NAME

Hypersonic::Event::IOCP - I/O Completion Ports backend for Windows

SYNOPSIS

use Hypersonic::Event;

my $backend = Hypersonic::Event->backend('iocp');
# $backend is 'Hypersonic::Event::IOCP'

DESCRIPTION

Hypersonic::Event::IOCP is the I/O Completion Ports (IOCP) event backend for Hypersonic on Windows. IOCP is the highest-performance I/O mechanism available on Windows, designed for servers handling thousands of connections.

Unlike epoll/kqueue which are "readiness" based (notify when fd is ready), IOCP is "completion" based (notify when I/O operation completes). This requires a different programming model where operations are posted asynchronously and completions are retrieved later.

KEY DIFFERENCES FROM UNIX BACKENDS

  • Completion-based vs readiness-based

  • Uses OVERLAPPED structures for async I/O

  • AcceptEx for async accept operations

  • WSARecv/WSASend for async socket I/O

  • Thread pool friendly design

METHODS

name

my $name = Hypersonic::Event::IOCP->name;  # 'iocp'

Returns the backend name.

available

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

Returns true only on Windows (MSWin32).

includes

Returns the C #include directives needed for IOCP.

defines

Returns the C #define directives including operation type constants and the PER_IO_DATA structure.

event_struct

my $struct = Hypersonic::Event::IOCP->event_struct;  # 'OVERLAPPED_ENTRY'

Returns the C struct name used for completion entries.

extra_ldflags

my $flags = Hypersonic::Event::IOCP->extra_ldflags;  # '-lws2_32 -lmswsock'

Returns linker flags needed for Winsock2.

gen_create($builder, $listen_fd_var)

Generates C code to create an IOCP, associate the listen socket, load AcceptEx, and post the initial accept operation.

gen_add($builder, $loop_var, $fd_var)

Generates C code to associate a socket with IOCP and post a read operation.

gen_del($builder, $loop_var, $fd_var)

Generates C code to cancel pending I/O and close a socket.

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

Generates C code to wait for completions using GetQueuedCompletionStatusEx.

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

Generates C code to extract the socket and operation type from a completion.

gen_cleanup($builder)

Generates C code to close IOCP handle and cleanup Winsock.

PERFORMANCE

IOCP can handle 100,000+ concurrent connections efficiently due to:

  • Kernel-managed completion queue

  • Efficient thread pool integration

  • Zero-copy I/O paths available

  • Scalable to many cores

AVAILABILITY

Windows only (Windows NT 3.5 and later, including all modern Windows).

SEE ALSO

Hypersonic::Event, Hypersonic::Event::Role, Hypersonic::Event::Select

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.