您如何一起使用aio和epoll

您如何一起使用aio和epoll

本文介绍了回顾“您如何一起使用aio和epoll"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循如何在单个事件循环中同时使用AIO和epoll?.

事实上,Linux中有2个"aio" API.我相信io_ *系列的RedHat(?)开发的glibc和libaio中包含了POSIX aio(aio_ *系列功能).

There are in fact 2 "aio" APIs in linux.There's POSIX aio (the aio_* family of functions), included in glibc and libaio developed I believe by RedHat (?), the io_* family.

第一个允许通过aio_sigevent aiocb成员注册通知请求.可以很容易地将其与ppoll()/pselect()事件循环集成在一起.如果您想将POSIX aio与epoll()集成,则需要将信号转换为虚拟fd(可能是管道)上的事件,并通过epoll监听,同时以经典方式或通过ppoll/捕获信号选择.首选(普通信号处理机)的安全性取决于应用程序.也许在epoll上,但我并不完全了解它的内部结构.我可以安全地假设,如果我有一个基于epoll的应用程序,并且想添加POSIX aio支持,那我就搞砸了?这是我的问题.

The first one allows registration of notification requests via aio_sigevent aiocb member. That can be easily integrated with ppoll()/pselect() event loops. If you want to integrate POSIX aio with epoll() then you need to translate the signal into an event on a dummy fd (a pipe maybe) and listen for it with epoll, while catching the signal either in a classic manner or with ppoll/select. How safe is the first choice (normal sighandlers), depends on application. And maybe on epoll but i'm not fully aware of its internals. May I safely assume that if I have an epoll based app and I want to add POSIX aio support then I'm screwed? This was my question.

第二个AIO实现libaio确实可以与eventfd()一起使用(结构iocb的aio_resfd成员期望为零,或者eventfd可以将AIO结果传递给该成员).但这不是这本书. POSIX指定的,即.

The second AIO implementation, libaio - can be used indeed with eventfd() (struct iocb having an aio_resfd member that is expected to be zero or an eventfd to deliver AIO results to). But it's not by the book. POSIX-specified, that is.

我梦想自己成为* BSD用户,一切都清楚了.您具有POSIX AIO和kqueue()对AIO事件的支持.晶莹剔透.像其他很多东西一样.

I dream of myself being a *BSD user where everything is clear. You have the POSIX AIO and kqueue() support for AIO events. Crystal clear. Like many other things.

推荐答案

请注意,您可以将POSIX aio与epoll一起使用,其中signalfd(2)它会创建一个文件描述符,然后您可以使用该文件描述符在基于epoll的循环中收到信号通知

note you CAN use POSIX aio with epoll, there's signalfd(2) it creates a file descriptor that you can then use to be notified of signals in an epoll based loop.

第二个aio API最终应该是glibc的基础,它是POSIX aio的实现基础,但还不存在……(我也不知道是否有人在使用它)

Also the second aio API is supposed to eventually be what glibc bases it's implementation of POSIX aio on, it's just not quite there yet... (I don't know if anyone is working on it either)

这篇关于回顾“您如何一起使用aio和epoll"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:56