mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-01 21:48:41 +00:00
Add a shared multi-file background writer with lazy worker startup. Represent PDB output as a file artifact, keep PDB output state internal to the builder, and overlap deferred PDB writers with the file maps release.
67 lines
2.8 KiB
C
67 lines
2.8 KiB
C
#pragma once
|
|
|
|
typedef U32 LNK_IO_Flags;
|
|
enum
|
|
{
|
|
LNK_IO_Flags_MemoryMapFilesReadOnly = (1 << 0),
|
|
LNK_IO_Flags_MemoryMapFilesReadWrite = (1 << 1),
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
LNK_IO_Flags io_flags;
|
|
String8Array path_arr;
|
|
String8Array data_arr;
|
|
File *handle_arr;
|
|
U64 *size_arr;
|
|
U64 *off_arr;
|
|
U8 *buffer;
|
|
} LNK_DiskReader;
|
|
|
|
typedef struct
|
|
{
|
|
String8List data;
|
|
} LNK_FileArtifact;
|
|
|
|
typedef struct LNK_BackgroundFile LNK_BackgroundFile;
|
|
|
|
typedef struct
|
|
{
|
|
Arena *queue_arena;
|
|
GuardedRing *queue;
|
|
Thread thread;
|
|
LNK_BackgroundFile *file_first;
|
|
LNK_BackgroundFile *file_last;
|
|
B32 is_running;
|
|
} LNK_BackgroundFileWriter;
|
|
|
|
// --- Shared File API ---------------------------------------------------------
|
|
|
|
shared_function int lnk_open_file_read(char *path, uint64_t path_size, void *handle_buffer, uint64_t handle_buffer_max);
|
|
shared_function int lnk_open_file_write(char *path, uint64_t path_size, void *handle_buffer, uint64_t handle_buffer_max);
|
|
shared_function void lnk_close_file(void *raw_handle);
|
|
shared_function uint64_t lnk_size_from_file(void *raw_handle);
|
|
shared_function uint64_t lnk_read_file(void *raw_handle, void *buffer, uint64_t buffer_max);
|
|
shared_function uint64_t lnk_write_file(void *raw_handle, uint64_t offset, void *buffer, uint64_t buffer_size);
|
|
|
|
// --- IO Functions ------------------------------------------------------------
|
|
|
|
internal File lnk_file_open_with_rename_permissions(String8 path);
|
|
internal B32 lnk_file_set_delete_on_close(File handle, B32 delete_file);
|
|
internal B32 lnk_file_rename(File handle, String8 new_name);
|
|
|
|
internal String8 lnk_read_data_from_file_path(Arena *arena, LNK_IO_Flags io_flags, String8 path);
|
|
internal String8Array lnk_read_data_from_file_path_parallel(TP_Context *tp, Arena *arena, LNK_IO_Flags io_flags, String8Array path_arr);
|
|
|
|
internal void lnk_write_data_list_to_file_path(String8 path, String8 temp_path, String8List list);
|
|
internal void lnk_write_data_to_file_path(String8 path, String8 temp_path, String8 data);
|
|
internal String8 lnk_data_from_file_artifact(Arena *arena, LNK_FileArtifact *artifact);
|
|
|
|
// --- Background Writer -------------------------------------------------------
|
|
|
|
internal void lnk_background_file_writer_begin (LNK_BackgroundFileWriter *writer);
|
|
internal LNK_BackgroundFile *lnk_background_file_writer_begin_file(LNK_BackgroundFileWriter *writer, String8 path, String8 temp_path);
|
|
internal void lnk_background_file_writer_enqueue (LNK_BackgroundFileWriter *writer, LNK_BackgroundFile *file, U64 file_off, String8 data);
|
|
internal void lnk_background_file_writer_end_file (LNK_BackgroundFileWriter *writer, LNK_BackgroundFile *file, U64 expected_byte_count);
|
|
internal void lnk_background_file_writer_end (LNK_BackgroundFileWriter *writer);
|