Implementing simple MPMC queue
Rewrinting the pipeline and progress display
This commit is contained in:
37
platform.h
37
platform.h
@@ -26,14 +26,14 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define XXH_VECTOR XXH_AVX2 // not recommanded to compile with gcc see xxhash.h line 4082
|
||||
// Must compile with /arch:AVX2 in clang-cl or -mavx2 in clang/gcc
|
||||
#define XXH_VECTOR \
|
||||
XXH_AVX2 // not recommanded to compile with gcc see xxhash.h line 4082
|
||||
// Must compile with /arch:AVX2 in clang-cl or -mavx2 in clang/gcc
|
||||
#define XXH_INLINE_ALL
|
||||
#include "xxhash.c"
|
||||
#include "xxhash.h"
|
||||
|
||||
// ----------------------------- Config -------------------------------------
|
||||
#define FILE_LIST_TXT "file_list.txt"
|
||||
#define FILE_HASHES_TXT "file_hashes.txt"
|
||||
#define HASH_STRLEN 33 // 128-bit hex (32 chars) + null
|
||||
#define MAX_PATHLEN 4096
|
||||
@@ -95,17 +95,32 @@ static double timer_stop(HiResTimer *t) {
|
||||
(double)g_qpc_freq.QuadPart;
|
||||
}
|
||||
|
||||
/* Scan folders */
|
||||
typedef struct EntryBuffer {
|
||||
FileEntry *entries;
|
||||
size_t count;
|
||||
size_t capacity;
|
||||
} EntryBuffer;
|
||||
// ============================================================
|
||||
// Simple Mutex-Based MPMC Queue (FileEntry*)
|
||||
// ============================================================
|
||||
|
||||
typedef struct {
|
||||
FileEntry **items;
|
||||
|
||||
size_t capacity;
|
||||
size_t head;
|
||||
size_t tail;
|
||||
size_t count;
|
||||
|
||||
int producers_active;
|
||||
|
||||
CRITICAL_SECTION cs;
|
||||
CONDITION_VARIABLE not_empty;
|
||||
CONDITION_VARIABLE not_full;
|
||||
|
||||
} MPMCQueue;
|
||||
|
||||
static MPMCQueue g_file_queue;
|
||||
|
||||
/* Scan folders */
|
||||
typedef struct DirQueue DirQueue;
|
||||
|
||||
void scan_folder_windows_parallel(const char *base, DirQueue *q,
|
||||
EntryBuffer *buf);
|
||||
void scan_folder_windows_parallel(const char *base, DirQueue *q);
|
||||
void scan_folder_posix_parallel(const char *base, DirQueue *q);
|
||||
|
||||
typedef struct DirJob {
|
||||
|
||||
Reference in New Issue
Block a user