uring落盘的无锁队列修改
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdatomic.h>
|
||||
|
||||
typedef enum { TASK_READ, TASK_WRITE } task_op_t;
|
||||
|
||||
@@ -24,30 +24,28 @@ typedef struct task {
|
||||
struct iovec *iovs; // iovec 数组
|
||||
int iovcnt; // iovec 数量
|
||||
|
||||
pthread_mutex_t m;
|
||||
pthread_cond_t cv;
|
||||
|
||||
struct task *next;
|
||||
} task_t;
|
||||
|
||||
typedef struct {
|
||||
_Atomic(task_t *) head;
|
||||
} task_stack_t;
|
||||
|
||||
typedef struct {
|
||||
_Atomic(task_t *) head;
|
||||
} destroy_queue_t;
|
||||
|
||||
typedef struct {
|
||||
struct io_uring ring;
|
||||
pthread_t th;
|
||||
|
||||
pthread_mutex_t q_m;
|
||||
pthread_cond_t q_cv;
|
||||
task_t *q_head, *q_tail;
|
||||
int event_fd;
|
||||
|
||||
int stop;
|
||||
atomic_int in_flight;
|
||||
_Atomic int in_flight;
|
||||
int max_in_flight;
|
||||
} iouring_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
task_t *head;
|
||||
pthread_mutex_t lock;
|
||||
} destroy_queue_t;
|
||||
|
||||
|
||||
void task_init(task_t *t);
|
||||
void task_finish(task_t *t, int res);
|
||||
|
||||
Reference in New Issue
Block a user