mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-16 16:01:26 -07:00
Clean up mutex usage in the parser
This commit is contained in:
+29
-22
@@ -62,15 +62,6 @@ enum PackageKind {
|
||||
Package_Init,
|
||||
};
|
||||
|
||||
struct ImportedPackage {
|
||||
PackageKind kind;
|
||||
String path;
|
||||
String rel_path;
|
||||
TokenPos pos; // import
|
||||
isize index;
|
||||
};
|
||||
|
||||
|
||||
struct ImportedFile {
|
||||
AstPackage *pkg;
|
||||
FileInfo fi;
|
||||
@@ -182,6 +173,9 @@ struct AstPackage {
|
||||
bool is_single_file;
|
||||
isize order;
|
||||
|
||||
BlockingMutex files_mutex;
|
||||
BlockingMutex foreign_files_mutex;
|
||||
|
||||
MPMCQueue<AstPackageExportedEntity> exported_entity_queue;
|
||||
|
||||
// NOTE(bill): Created/set in checker
|
||||
@@ -191,20 +185,33 @@ struct AstPackage {
|
||||
};
|
||||
|
||||
|
||||
struct ParseFileErrorNode {
|
||||
ParseFileErrorNode *next, *prev;
|
||||
ParseFileError err;
|
||||
};
|
||||
|
||||
struct Parser {
|
||||
String init_fullpath;
|
||||
StringSet imported_files; // fullpath
|
||||
Array<AstPackage *> packages;
|
||||
Array<ImportedPackage> package_imports;
|
||||
isize file_to_process_count;
|
||||
isize total_token_count;
|
||||
isize total_line_count;
|
||||
BlockingMutex wait_mutex;
|
||||
BlockingMutex import_mutex;
|
||||
BlockingMutex file_add_mutex;
|
||||
BlockingMutex file_decl_mutex;
|
||||
BlockingMutex packages_mutex;
|
||||
MPMCQueue<ParseFileError> file_error_queue;
|
||||
String init_fullpath;
|
||||
|
||||
StringSet imported_files; // fullpath
|
||||
BlockingMutex imported_files_mutex;
|
||||
|
||||
Array<AstPackage *> packages;
|
||||
BlockingMutex packages_mutex;
|
||||
|
||||
std::atomic<isize> file_to_process_count;
|
||||
std::atomic<isize> total_token_count;
|
||||
std::atomic<isize> total_line_count;
|
||||
|
||||
// TODO(bill): What should this mutex be per?
|
||||
// * Parser
|
||||
// * Package
|
||||
// * File
|
||||
BlockingMutex file_decl_mutex;
|
||||
|
||||
BlockingMutex file_error_mutex;
|
||||
ParseFileErrorNode * file_error_head;
|
||||
ParseFileErrorNode * file_error_tail;
|
||||
};
|
||||
|
||||
struct ParserWorkerData {
|
||||
|
||||
Reference in New Issue
Block a user