Improving the lock free mpmc queue
Making the queue growable Add padding to avoir false sharing Add sleep() and SwitchToThread() to limit spinning
This commit is contained in:
12
platform.h
12
platform.h
@@ -103,16 +103,22 @@ static double timer_stop(HiResTimer *t) {
|
||||
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;
|
||||
|
||||
MPMCSlot *slots;
|
||||
atomic_size_t committed;
|
||||
size_t commit_step;
|
||||
|
||||
atomic_size_t head;
|
||||
atomic_size_t tail;
|
||||
MPMCSlot *slots;
|
||||
} MPMCQueue;
|
||||
|
||||
static MPMCQueue g_file_queue;
|
||||
|
||||
Reference in New Issue
Block a user