From 90e98f2f64d6700114c8e20c98a88e9814fb49ca Mon Sep 17 00:00:00 2001 From: romir kulshrestha Date: Wed, 4 Mar 2026 20:18:49 +0100 Subject: docstrs --- oryxc/src/compiler.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'oryxc') diff --git a/oryxc/src/compiler.rs b/oryxc/src/compiler.rs index b806a9e..0d1c65d 100644 --- a/oryxc/src/compiler.rs +++ b/oryxc/src/compiler.rs @@ -49,6 +49,7 @@ pub struct FileData { } impl FileData { + /// Read a source file from disk and create a new [`FileData`]. fn new(name: OsString) -> Result { const PAD: [u8; 64] = [0; 64]; /* 512 bits */ @@ -87,6 +88,7 @@ pub struct CompilerState { } impl CompilerState { + /// Unpark all worker threads. fn wake_all(&self) { if let Some(threads) = self.worker_threads.get() { for t in threads.iter() { @@ -95,12 +97,14 @@ impl CompilerState { } } + /// Push a job onto a worker's local queue and wake all threads. fn push_job(&self, queue: &Worker, job: Job) { queue.push(job); self.wake_all(); } } +/// Initialize compiler state and drive all source files through the pipeline. pub fn start(paths: T, flags: Flags) where T: IntoIterator, @@ -164,15 +168,7 @@ where } } -fn emit_errors(fdata: &FileData, errors: T) -where - T: IntoIterator, -{ - for e in errors { - e.report(&fdata.name, &fdata.buffer); - } -} - +/// Steal and execute jobs until all work is complete. fn worker_loop( _id: usize, state: Arc, @@ -242,6 +238,7 @@ fn worker_loop( } } +/// Get next available job or steal from the global queue or peers if local queue is empty. fn find_task( localq: &Worker, globalq: &Injector, @@ -271,3 +268,13 @@ fn find_task( None } + +/// Print all errors to stderr using the file's name and source buffer. +fn emit_errors(fdata: &FileData, errors: T) +where + T: IntoIterator, +{ + for e in errors { + e.report(&fdata.name, &fdata.buffer); + } +} -- cgit v1.2.3