Windows 上最好的 epoll/kqueue/select 等效项是什么?
Windows 最好的 I/O 事件通知工具是什么?
最好的意思是...
- 对输入文件描述符的数量没有限制
- 适用于所有文件描述符(磁盘文件,套接字...)
- 提供各种通知模式(边缘触发,限制触发)
What is Windows' best I/O event notification facility?
By best I mean something that ...
- doesn't have a limit on number of input file descriptors
- works on all file descriptors (disk files, sockets, ...)
- provides various notification modes (edge triggered, limit triggered)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在Windows中,异步操作是通过文件操作完成的,而不是通过描述符完成的。 有多种方法可以异步等待文件操作完成。
例如,如果您想知道网络套接字上的数据何时可用,请在套接字上发出异步读取请求,当请求完成时,数据可用并已被检索。
在 Win32 中,异步操作使用
OVERLAPPED
结构包含有关未完成 IO 操作的状态。WaitForMultipleObjects
来立即等待所有事件。 这样做的缺点是只能一次等待MAXIMUM_WAIT_OBJECTS
对象 (64)。 您还可以同时等待其他类型的事件(进程/线程终止、互斥体、事件、信号量)ReadFileEx
和WriteFileEx
到队列对调用线程的异步过程调用 (APC)和SleepEx
(或WaitFor{Single|Multiple}ObjectsEx
) 和Alertable TRUE
在每个操作完成时接收通知消息。 该方法类似于IO完成端口,但仅适用于一个线程。Windows NT 内核在内部不区分套接字、磁盘文件、管道等文件操作:所有这些选项都适用于所有文件类型。
In Windows, async operations are done by file operation, not by descriptor. There are several ways to wait on file operations to complete asynchronously.
For example, if you want to know when data is available on a network socket, issue an async read request on the socket and when it completes, the data was available and was retrieved.
In Win32, async operations use the
OVERLAPPED
structure to contain state about an outstanding IO operation.WaitForMultipleObjects
to wait on all the events at once. This has the disadvantage of only being able to wait onMAXIMUM_WAIT_OBJECTS
objects at once (64). You can also wait on other types of events at the same time (process/thread termination, mutexes, events, semaphores)ReadFileEx
andWriteFileEx
to queue Asynchronous Procedure Calls (APCs) to the calling thread andSleepEx
(orWaitFor{Single|Multiple}ObjectsEx
) withAlertable TRUE
to receive a notification message for each operation when it completes. This method is similar to an IO completion port, but only works for one thread.The Windows NT kernel makes no distinction between socket, disk file, pipe, etc. file operations internally: all of these options will work with all the file types.
libuv
libuv
为 Unix 和 Windows 提供事件 I/O,并支持套接字、文件和管道。 它是 Node.js 的平台层。更多详细信息请访问:http://nikhilm.github.io/uvbook/introduction.html
libuv
libuv
offers evented I/O for Unix and Windows and has support for socket, files and pipes. It is the platform layer of Node.js.More details are at: http://nikhilm.github.io/uvbook/introduction.html
据我所知,还没有一个。 我和一个朋友正在开发一个开源 Windows epoll 实现(链接如下),但我们在弄清楚如何使其与 Linux 实现的行为相同方面遇到了问题。
当前的障碍:
随着项目取得进展,我会尝试回来更新这篇文章。
http://sourceforge.net/projects/cpoll
There isn't one yet, as far as I am aware. A friend and I are working on an open source Windows epoll implementation (link below) but we're running into issues figuring out how to make it act the same as the Linux implementation.
Current obstacles:
I'll try to come back and update this post as we make progress with the project.
http://sourceforge.net/projects/cpoll
select() 函数是 POSIX 函数,可在 Windows 上使用,包括“winsock.h”或“winsock2.h”。
select() function is POSIX and usable on windows including "winsock.h" or "winsock2.h".