luaur_analysis/methods/frontend_perform_queue_item_task.rs
1use crate::records::build_queue_work_state::BuildQueueWorkState;
2use crate::records::frontend::Frontend;
3use alloc::sync::Arc;
4
5impl Frontend {
6 pub fn perform_queue_item_task(&mut self, state: Arc<BuildQueueWorkState>, item_pos: usize) {
7 // SAFETY: `state` is shared across the (logically concurrent) build queue.
8 // The C++ relies on `state` being a `shared_ptr` whose `BuildQueueItem`s are
9 // mutated in place while synchronization is provided by `state->mtx`. We mirror
10 // that by taking a `*mut` through the `Arc`.
11 let state_ptr = Arc::as_ptr(&state) as *mut BuildQueueWorkState;
12
13 // C++ wraps this in `try { ... } catch (const InternalCompilerError&)`,
14 // recording the exception into `item.exception`. The Rust port models an ICE
15 // as a panic (matching the rest of the codebase), so there is no catch here;
16 // `item.exception` remains `None` on the success path.
17 {
18 let items = unsafe { &mut (*state_ptr).build_queue_items };
19 let item = &mut items[item_pos];
20 self.check_build_queue_item(item);
21 }
22
23 {
24 let mtx = unsafe { &(*state_ptr).mtx };
25 let _guard = mtx.lock().unwrap();
26 let ready = unsafe { &mut (*state_ptr).ready_queue_items };
27 ready.push(item_pos);
28 }
29
30 let cv = unsafe { &(*state_ptr).cv };
31 cv.notify_one();
32 }
33}