Skip to content

Add native async I/O and an event loop with Fiber integratio #70

Description

@TrixNEW

Summary

zphp should provide a built-in async I/O runtime so PHP applications can handle large numbers of concurrent operations without blocking OS threads.

The event loop should use the best native backend available per platform, such as:

  • epoll on Linux
  • kqueue on macOS/BSD
  • IOCP on Windows

It should integrate directly with PHP Fibers.

For example:

$data = await($socket->read());

Instead of blocking the thread, the current Fiber should suspend until the operation completes.

Initial scope

Support:

  • TCP/UDP sockets
  • timers
  • DNS
  • file descriptors/streams where practical
  • cancellation
  • timeouts
  • wakeups
  • Fiber suspension/resume

The runtime should avoid busy polling and unnecessary allocations.

Ideally there should be one reusable event-loop implementation that extensions and higher-level PHP libraries can build on.

Goals

  • high concurrency with low thread count
  • low idle CPU usage
  • efficient native polling
  • no blocking of unrelated Fibers
  • clean cancellation/shutdown
  • no leaks or dangling callbacks
  • usable independently of zphp serve

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions