File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use core:: { future:: Future , pin:: Pin , task:: { Context , Poll } } ;
22use alloc:: boxed:: Box ;
3+ use crossbeam_queue:: ArrayQueue ;
4+ use conquer_once:: spin:: OnceCell ;
5+ use crate :: vfs:: CachedVfsBlock ;
36
47pub mod executor;
58pub mod keyboard;
@@ -21,32 +24,32 @@ impl Task {
2124 }
2225}
2326
24- use crate :: vfs:: CachedVfsBlock ;
25-
2627#[ derive( Clone , Copy ) ]
2728pub struct CryptoVerificationJob {
2829 pub block_ptr : * mut CachedVfsBlock ,
2930 pub expected_hash : [ u8 ; 32 ] ,
3031}
3132
32- pub struct VerificationQueue {
33- pub jobs : [ Option < CryptoVerificationJob > ; 32 ] ,
34- pub head : usize ,
35- pub tail : usize ,
33+ // Global thread-safe async queue for block validation
34+ pub static VERIFICATION_QUEUE : OnceCell < ArrayQueue < CryptoVerificationJob > > = OnceCell :: new ( ) ;
35+
36+ pub fn init_queue ( ) {
37+ VERIFICATION_QUEUE . init_once ( || ArrayQueue :: new ( 32 ) ) ;
3638}
3739
3840pub fn spawn_provenance_worker ( ) {
39-
4041 loop {
4142 if let Some ( queue) = VERIFICATION_QUEUE . get ( ) {
4243 if let Some ( job) = queue. pop ( ) {
43- // Execute the cryptographic hashing off the main thread path
4444 unsafe {
4545 crate :: provenance:: process_next_provenance_job ( job) ;
4646 }
4747 }
4848 }
49- // Prevent raw CPU hogging in simulation
5049 core:: hint:: spin_loop ( ) ;
5150 }
51+ }
52+
53+ pub fn yield_current_thread ( ) {
54+ core:: hint:: spin_loop ( ) ;
5255}
You can’t perform that action at this time.
0 commit comments