45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
|
|
#ifndef _IO_URING_H_
|
||
|
|
#define _IO_URING_H_
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C"
|
||
|
|
{
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#define MAX_BATCH_CQE_NUM 128
|
||
|
|
|
||
|
|
struct io_uring_instance;
|
||
|
|
|
||
|
|
/*
|
||
|
|
* ring_size : 1024
|
||
|
|
* buff_size : 2048
|
||
|
|
* flags : 0
|
||
|
|
* IORING_SETUP_IOPOLL(1U << 0) io_context is polled
|
||
|
|
* IORING_SETUP_SQPOLL(1U << 1) SQ poll thread
|
||
|
|
* IORING_SETUP_SQ_AFF(1U << 2) sq_thread_cpu is valid
|
||
|
|
* ORING_SETUP_CQSIZE(1U << 3) app defines CQ size
|
||
|
|
* IORING_SETUP_CLAMP(1U << 4) clamp SQ/CQ ring sizes
|
||
|
|
* IORING_SETUP_ATTACH_WQ(1U << 5) attach to existing wq
|
||
|
|
* IORING_SETUP_R_DISABLED(1U << 6) start with ring disabled
|
||
|
|
* IORING_SETUP_SUBMIT_ALL(1U << 7) continue submit on error
|
||
|
|
* sq_thread_idle : 0
|
||
|
|
*/
|
||
|
|
struct io_uring_instance *io_uring_instance_create(int sockfd, int eventfd, int ring_size, int buff_size, int flags, int sq_thread_idle, int enable_debug);
|
||
|
|
void io_uring_instance_destory(struct io_uring_instance *instance);
|
||
|
|
|
||
|
|
typedef void read_callback(const char *data, int len, void *args);
|
||
|
|
// return 0 : success
|
||
|
|
// reutrn -1 : error
|
||
|
|
int io_uring_register_read_callback(struct io_uring_instance *instance, read_callback *read_cb, void *cb_arg);
|
||
|
|
// return 0 : success
|
||
|
|
// reutrn -1 : error
|
||
|
|
int io_uring_submit_write_entry(struct io_uring_instance *instance, const char *data, int len);
|
||
|
|
// returns the number of processed entrys
|
||
|
|
int io_uring_peek_ready_entrys(struct io_uring_instance *instance);
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif
|