Making the LF MPMC queue generic and isolating it's code in a separate header file
This commit is contained in:
28
platform.h
28
platform.h
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "arena.h"
|
||||
#include "base.h"
|
||||
#include "lf_mpmc.h"
|
||||
|
||||
#include "arena.c"
|
||||
// ----------------------------- Config -------------------------------------
|
||||
@@ -44,32 +45,7 @@ static double timer_stop(HiResTimer *t) {
|
||||
(double)g_qpc_freq.QuadPart;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Simple lock free MPMC Queue
|
||||
// ============================================================
|
||||
|
||||
typedef struct {
|
||||
atomic_size_t seq;
|
||||
FileEntry *data;
|
||||
char pad[64 - sizeof(atomic_size_t) - sizeof(FileEntry *)];
|
||||
} MPMCSlot;
|
||||
|
||||
typedef struct {
|
||||
atomic_size_t head;
|
||||
char pad1[64];
|
||||
atomic_size_t tail;
|
||||
char pad2[64];
|
||||
|
||||
size_t capacity;
|
||||
size_t mask;
|
||||
|
||||
atomic_size_t committed;
|
||||
size_t commit_step;
|
||||
atomic_flag commit_lock;
|
||||
|
||||
MPMCSlot *slots;
|
||||
} MPMCQueue;
|
||||
|
||||
// MPMC Queue
|
||||
static MPMCQueue g_file_queue;
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user