官网:https://oss.oracle.com/projects/libaio-oracle/,正如标题所说,非常简单了,不用多解释,请直接看头文件,其中aio_poll类似于poll,重要的结构是aiocb64,类似于epoll_event。

#ifndef _SKGAIO_H
#define _SKGAIO_H #define IOCB_CMD_READ 0
#define IOCB_CMD_WRITE 1
#define IOCB_CMD_NOP 2
#define IOCB_CMD_CANCEL 3
#define IOCB_CMD_FSYNC 4
#define IOCB_CMD_FDSYNC 5
#define IOCB_CMD_RUNNING 6
#define IOCB_CMD_DONE 7 /* Maximum number of events to retrieve at once */
#define MAX_EVENTS 512
#define MAX_AIO_REAP MAX_EVENTS #include <stdlib.h>
#include <asm/unistd.h>
#include <linux/types.h>
#include <signal.h>
/*
* we always use a 64bit off_t when communicating
* with userland. its up to libraries to do the
* proper padding and aio_error abstraction
*
* FIXME: this must change from glibc's definition
* as we do *not* use the sigevent structure which
* is big and bloated.
*/
struct aiocb64 {
int aio_fildes; /* File desriptor. */
short aio_lio_opcode; /* Operation to be performed. */
short aio_reqprio; /* Request priority offset. */
void *aio_buf; /* Location of buffer. */
size_t aio_nbytes; /* Length of transfer. */
loff_t aio_offset; /* File offset. */
/* these are internal to the kernel/libc. */
long __aio_key; // kernel sets this to -1 if completed
// otherwise >= 0 (the request#)
void * __aio_data; // pointer to be returned in event's data
int __error_code;
}; #ifdef DEBUG
#define dbg_printf(fmt,arg...)\
printf(fmt, ##arg)
#else
#define dbg_printf(fmt,arg...)\
do { } while(0);
#endif #define aiocb aiocb64
#define aio_read aio_read64
#define aio_write aio_write64
#define aio_poll aio_poll64
#define aio_error aio_error64
#define aio_return aio_return64
#define aio_cancel aio_cancel64
#define aio_suspend aio_suspend64
#define lio_listio lio_listio64
#define aio_reap aio_reap64 /* Initialize async i/o with the given maximum number of requests */
int aio_init(int max_requests); /* Enqueue read request for given number of bytes and the given priority. */
int aio_read64(struct aiocb64 *aiocbp); /* Enqueue write request for given number of bytes and the given priority. */
int aio_write64(struct aiocb64 *aiocbp); /* Enqueue a poll request for a given fd. */
int aio_poll64(struct aiocb64 *aiocbp); /*
* Returns the status of the aiocb.
* If the operation is incomplete, the return value is undefined
* < -1 is -errno for the call.
* >= -1 is the return code of the completed operation
*/
ssize_t aio_return64(struct aiocb64 *aiocbp); /*
* Returns the error status of the aiocb.
* < 0 is -errno for the call.
* 0 is successfully complete
* EINPROGRESS is not complete at all.
* > 0 is errno for unsuccessful completion.
*/
int aio_error64(struct aiocb64 *aiocbp); /*
* Try to cancel asynchronous I/O requests outstanding against file
* descriptor FILDES.
*/
int aio_cancel64 ( int fildes, struct aiocb64 *aiocbp); /*
* Suspend calling thread until at least one of the asynchronous I/O
* operations referenced by LIST has completed.
*/
int aio_suspend64(const struct aiocb64 * const list[],int nent,
const struct timespec *timeout); /*
* Suspend calling thread until waitfor asynchronouse I/O operations
* outstanding have completed.
*/
int aio_reap64(struct timespec *timeout, int waitfor,
struct aiocb *out_list[], int listsize,
int *completed_count); int lio_listio64(int mode, struct aiocb64 * const list[], int nent,
struct sigevent *__restrict __sig); /* Operation codes for `aio_lio_opcode'. */
enum
{
LIO_READ,
#define LIO_READ LIO_READ
LIO_WRITE,
#define LIO_WRITE LIO_WRITE
LIO_NOP,
#define LIO_NOP LIO_NOP
LIO_POLL,
#define LIO_POLL LIO_POLL
}; /* Return values of cancelation function. */
enum
{
AIO_CANCELED,
#define AIO_CANCELED AIO_CANCELED
AIO_NOTCANCELED,
#define AIO_NOTCANCELED AIO_NOTCANCELED
AIO_ALLDONE
#define AIO_ALLDONE AIO_ALLDONE
}; /* Synchronization options for `lio_listio' function. */
enum
{
LIO_WAIT,
#define LIO_WAIT LIO_WAIT
LIO_NOWAIT
#define LIO_NOWAIT LIO_NOWAIT
}; #endif /* _SKGAIO_H */

Orace开源的异步IO编程库,特点是接口非常简单的更多相关文章

  1. python异步IO编程(一)

    python异步IO编程(一) 基础概念 协程:python  generator与coroutine 异步IO (async IO):一种由多种语言实现的与语言无关的范例(或模型). asyncio ...

  2. python异步IO编程(二)

    python异步IO编程(二) 目录 开门见山 Async IO设计模式 事件循环 asyncio 中的其他顶层函数 开门见山 下面我们用两个简单的例子来让你对异步IO有所了解 import asyn ...

  3. Java IO编程全解(三)——伪异步IO编程

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/7723174.html 前面讲到:Java IO编程全解(二)--传统的BIO编程 为了解决同步阻塞I/O面临 ...

  4. Java IO编程全解(四)——NIO编程

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/7793964.html 前面讲到:Java IO编程全解(三)——伪异步IO编程 NIO,即New I/O,这 ...

  5. Java IO编程全解(二)——传统的BIO编程

    前面讲到:Java IO编程全解(一)——Java的I/O演进之路 网络编程的基本模型是Client/Server模型,也就是两个进程之间进行相互通信,其中服务端提供位置信息(绑定的IP地址和监听端口 ...

  6. 通过生成器yield实现单线程的情况下实现并发运算效果(异步IO的雏形)

    一.协程: 1.生成器只有在调用时才会生成相应的数据 2.调用方式有 " str__next__.()   str.send() ", 3.并且每调用一次就产生一个值调用到最后一个 ...

  7. Python并发编程之初识异步IO框架:asyncio 上篇(九)

    大家好,并发编程 进入第九篇. 通过前两节的铺垫(关于协程的使用),今天我们终于可以来介绍我们整个系列的重点 -- asyncio. asyncio是Python 3.4版本引入的标准库,直接内置了对 ...

  8. 【译】深入理解python3.4中Asyncio库与Node.js的异步IO机制

    转载自http://xidui.github.io/2015/10/29/%E6%B7%B1%E5%85%A5%E7%90%86%E8%A7%A3python3-4-Asyncio%E5%BA%93% ...

  9. Python高级编程和异步IO并发编程

    第1章 课程简介介绍如何配置系统的开发环境以及如何加入github私人仓库获取最新源码. 1-1 导学 试看 1-2 开发环境配置 1-3 资源获取方式第2章 python中一切皆对象本章节首先对比静 ...

随机推荐

  1. bzoj 4310 跳蚤——后缀数组+二分答案+贪心

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4310 答案有单调性? 二分出来一个子串,判断的时候需要满足那些字典序比它大的子串都不出现! ...

  2. 利用脚本启动java程序

    今天在工作中,需要写一个shell脚本,启动一个socket程序,从而模拟短信网关.查了一些资料,终于搞定了,现在记录一下,方便大家查阅. 为了说明使用方法,我们就用最简单的程序来实现,比如我们要运行 ...

  3. Kaggle 比赛项目总结(项目流程)

    一.EDA(Exploratory Data Analysis) EDA:也就是探索性的分析数据 目的: 理解每个特征的意义: 知道哪些特征是有用的,这些特征哪些是直接可以用的,哪些需要经过变换才能用 ...

  4. 圆周率的现代计算机求法(C语言) Lebal:research

    C语言求圆周率π 公式法1 #include <stdio.h> #include <math.h> int main(){ float term,result=1; int ...

  5. CentOS下安装桌面环境

    1. 使用 yum grouplist 查看可用的 group 2. 使用 yum groupinstall 进行安装.例如:yum groupinstall GNOME Desktop

  6. MVC中Ajax post 和Ajax Get——提交对象Model

    HTTP 请求:GET vs. POST两种在客户端和服务器端进行请求-响应的常用方法是:GET 和 POST.GET - 从指定的资源请求数据POST - 向指定的资源提交要处理的数据GET 基本上 ...

  7. Windows下搭建PHP开发环境-WEB服务器

    PHP集成开发环境有很多,如XAMPP.AppServ......只要一键安装就把PHP环境给搭建好了.但这种安装方式不够灵活,软件的自由组合不方便,同时也不利于学习.所以我还是喜欢手工搭建PHP开发 ...

  8. java - 只输出不含中文标点符号的中文

    String a ="12dss显示,‘:()中文只"; StringBuffer b = new StringBuffer(); for(int i = 0;i<a.len ...

  9. python构造远控

    server端: import socket import subprocess server=socket.socket() server.bind(('127.0.0.1',4444)) serv ...

  10. springboot整合redis单机及集群

    一.单机配置 properties配置 #单机redis spring.redis.host=127.0.0.1 spring.redis.port=6379 spring.redis.passwor ...