Orace开源的异步IO编程库,特点是接口非常简单
来源:互联网 发布:js插件应该怎样使用 编辑:程序博客网 时间:2024/05/16 09:11
官网:https://oss.oracle.com/projects/libaio-oracle/,正如标题所说,非常简单了,不用多解释,请直接看头文件,其中aio_poll类似于poll,重要的结构是aiocb64,类似于epoll_event。
#ifndef _SKGAIO_H#define _SKGAIO_H#define IOCB_CMD_READ0#define IOCB_CMD_WRITE1#define IOCB_CMD_NOP2#define IOCB_CMD_CANCEL3#define IOCB_CMD_FSYNC4#define IOCB_CMD_FDSYNC5#define IOCB_CMD_RUNNING6#define IOCB_CMD_DONE7/* 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#definelio_listiolio_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 */
0 0
- Orace开源的异步IO编程库,特点是接口非常简单
- IASyncResult接口实现简单异步编程
- linux下异步IO的简单例子
- linux下异步IO的简单例子
- Linux异步IO的简单应用
- Winsock的编程特点与异步选择机制
- 非常简单的socket编程例子
- UIday1601:网络编程 GET POST 的同步或异步请求,服务器接口的简单介绍。
- Java IO的特点
- 伪异步IO编程
- 异步IO编程
- Linux下原生异步IO接口Libaio的用法
- 你的“重叠IO”是真正异步的吗?
- C# 接口的特点、接口的作用、接口的简单应用
- 接口的成员特点
- 接口的成员特点
- interface 接口的特点
- 接口的特点
- linux vim 配置文件.vimrc
- github简单使用教程
- 2.循环链表和双向链表
- mysql的索引原理探讨。
- (1)php的日期和时间
- Orace开源的异步IO编程库,特点是接口非常简单
- java中流的操作
- Oracle 11g SecureFiles 说明
- UVA 11039 Building designing
- Usermod 命令详解
- 最后期限
- (STL) ACM_擅长排列的小明.(补)
- wince6.0编译命令分析
- jdk 环境变量的设置