tidwall / neco

Concurrency library for C (coroutines)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[wish] Windows socket support with wepoll

skywind3000 opened this issue · comments

Want to try it on Windows, but it lacks network support.

Could you please provide an option to build with wepoll (https://github.com/piscisaureus/wepoll) ?
It is a fast epoll implementation for Windows and has exact same APIs of linux's epoll.

it is also as portable as neco itself (only require wepoll.h and wepoll.c).

Maybe it could be implemented as a plugin for neco, which is disabled by default, but can be enabled by defining
a macro:

#define NECO_HAS_WEPOLL  1

Another option is using a cross-platform select function, eg:

https://gist.github.com/skywind3000/6886b61898044b2d81962109e26dc63d

Neco for Windows needs some love for sure.

The biggest issue is that neco_wait() is not supported on Windows. This function waits for a file descriptor to be readable or writeable.

For example, this works on linux.

size_t n;
do {
    neco_wait(fd, NECO_WAIT_READ);
    n = neco_read(fd);
} while(n == -1 && errno == EAGAIN);

Under the hood, neco_wait automatically adds the file descriptor to epoll and waits for the scheduler to wake it back up.

Ideally Windows should do the same thing. I looked into using I/O Competion Ports, but I haven't had the time to implement it.

I would consider other solution too, but I'm not a Windows expert.