uring落盘的无锁队列修改

This commit is contained in:
1iaan
2026-02-11 11:59:40 +00:00
parent c1458a6693
commit 68bb4b3f9c
16 changed files with 293 additions and 1135 deletions

View File

@@ -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);