wepoll:快速epoll for windows下载
Bert Belder bde80b0938 version 1.2.4
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJaLqx0AAoJEHp3iHsuLtRhIGsH/19uFtGikwO+FKUhs+7+wyJL
 cu+SyL4VUYbR9qdTb3hwiwlJjkU0KaIGhEHvpjKykdEADhhMaHFMeSO5QYeVNnr+
 FI38O+JnmKbb17CtY9xmuRLhmurOj1TvNFF+pCbXoFTyI9uCc76Osdx9/9B1fPmV
 F1JBTHZSsEKivyWKeyfdbG+O1cAcXs1/NzPEvDlOeXO628GLTKD/G4Qa8l71+IKP
 Cj08vsSH5yZYXfTkR8CQNR1xAh9B5pGjH5nXX/++RxeZXBscGKzIK4JL2fbWTG24
 YS4FTbwaQAV+eTh/hbkk9bu7fdpAqYKLaQZ0cw4IAjigeozF8HqH2IJNp4KOitM=
 =Z2QT
 -----END PGP SIGNATURE-----

dist: merge release tag v1.2.4
2017-12-11 17:05:44 +01:00
include header: cast event types to uint32_t 2017-12-03 23:15:31 +01:00
src util: define static_assert even if clang pretends to be msvc 2017-12-10 05:51:48 +01:00
test test: squelch gcc -Wparentheses warning 2017-12-08 19:41:41 +01:00
tools build: rename 'all-in-one' to 'combined', store in 'dist/' 2017-11-30 23:33:45 +01:00
.appveyor.yml ci: add gcc and clang builds 2017-12-10 05:51:49 +01:00
.clang-format clang-format: add style for formatting javascript source 2017-09-10 20:40:43 +02:00
.gitignore gitignore: ignore some compiler outputs 2017-12-09 23:28:23 +01:00
CMakeLists.txt ci: add gcc and clang builds 2017-12-10 05:51:49 +01:00
LICENSE doc: add project name and blurb to license 2017-12-01 22:07:57 +01:00
README.md doc: update readme prose 2017-12-09 23:30:06 +01:00
tsfmt.json misc: add tsfmt.json 2017-11-24 19:15:02 +01:00

wepoll - epoll for windows

This library implements the epoll API for Windows applications. It is fast and scalable, and it closely resembles the API and behavior of Linux' epoll.

Rationale

Unlike Linux, OS X, and many other operating systems, Windows doesn't have a good API for receiving socket state notifications. It only supports the select and WSAPoll APIs, but they don't scale and suffer from other issues.

Using I/O completion ports isn't always practical when software is designed to be cross-platform. Wepoll offers an alternative that is much closer to a drop-in replacement for software that was designed to run on Linux.

Features

  • Can poll 100000s of sockets efficiently.
  • Fully thread-safe.
  • Multiple threads can poll the same epoll port.
  • Sockets can be added to multiple epoll sets.
  • All epoll events (EPOLLIN, EPOLLOUT, EPOLLPRI, EPOLLRDHUP) are supported.
  • Level-triggered and one-shot (EPOLLONESTHOT) modes are supported
  • Trivial to embed: you need only two files.

Limitations

  • Only works with sockets.
  • Edge-triggered (EPOLLET) mode isn't supported.

How to use

The library is distributed as a single source file (wepoll.c) and a single header file (wepoll.h). Compile the .c file as part of your project, and include the header wherever needed.

Compatibility

  • Requires Windows Vista or higher.
  • Can be compiled with recent versions of MSVC, Clang, and GCC.

API notes

General

  • The epoll port is a HANDLE, not a file descriptor.
  • All functions set both errno and GetLastError() on failure.

epoll_create/epoll_create1

HANDLE epoll_create(int size);
HANDLE epoll_create1(int flags);
  • Create a new epoll instance (port).
  • size is ignored but most be greater than zero.
  • flags must be zero as there are no supported flags.
  • Returns NULL on failure.
  • man page

epoll_close

int epoll_close(HANDLE ephnd);
  • Close an epoll port.
  • Do not attempt to close the epoll port with close(), CloseHandle() or closesocket().

epoll_ctl

int epoll_ctl(HANDLE ephnd,
              int op,
              SOCKET sock,
              struct epoll_event* event);
  • Control which socket events are monitored by an epoll port.
  • ephnd must be a HANDLE created by epoll_create or epoll_create1.
  • op must be one of EPOLL_CTL_ADD, EPOLL_CTL_MOD, EPOLL_CTL_DEL.
  • It is recommended to always explicitly remove a socket from its epoll set using EPOLL_CTL_DEL before closing it. As on Linux, sockets are automatically removed from the epoll set when they are closed, but wepoll may not be able to detect this until the next call to epoll_wait().
  • TODO: expand
  • man page

epoll_wait

int epoll_wait(HANDLE ephnd,
               struct epoll_event* events,
               int maxevents,
               int timeout);
  • Receive socket events from an epoll port.
  • Returns
    • -1 on failure
    • 0 when a timeout occurs
    • ≥1 the number of evens received
  • TODO: expand
  • man page