diff options
| author | gingerBill <bill@gingerbill.org> | 2022-12-22 12:45:23 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-12-22 12:45:23 +0000 |
| commit | 41b32f0da4b40295771e2a9a521b89464d98201b (patch) | |
| tree | 2ec16d095e5b22ef22bfbec7d6bd38f5e878628e /src/parser.hpp | |
| parent | c53b2198a86fff66225a53f22693d9b3bf6c28e5 (diff) | |
Clean up mutex usage in the parser
Diffstat (limited to 'src/parser.hpp')
| -rw-r--r-- | src/parser.hpp | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/parser.hpp b/src/parser.hpp index df882cc0f..4357573c9 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -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 { |