@@ -552,7 +552,7 @@ use livesplit_auto_splitting::{
552
552
Timer as AutoSplitTimer , TimerState ,
553
553
} ;
554
554
use snafu:: Snafu ;
555
- use std:: { cell :: RefCell , fmt, fs, io, path:: PathBuf , thread, time:: Duration } ;
555
+ use std:: { fmt, fs, io, path:: PathBuf , sync :: RwLock , thread, time:: Duration } ;
556
556
use tokio:: {
557
557
runtime,
558
558
sync:: watch,
@@ -588,7 +588,7 @@ pub struct Runtime<T> {
588
588
interrupt_receiver : watch:: Receiver < Option < InterruptHandle > > ,
589
589
auto_splitter : watch:: Sender < Option < AutoSplitter < Timer < T > > > > ,
590
590
runtime : livesplit_auto_splitting:: Runtime ,
591
- compiled_auto_splitter : RefCell < Option < CompiledAutoSplitter > > ,
591
+ compiled_auto_splitter : RwLock < Option < CompiledAutoSplitter > > ,
592
592
}
593
593
594
594
impl < T > Drop for Runtime < T > {
@@ -643,7 +643,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
643
643
auto_splitter : sender,
644
644
// TODO: unwrap?
645
645
runtime : livesplit_auto_splitting:: Runtime :: new ( Config :: default ( ) ) . unwrap ( ) ,
646
- compiled_auto_splitter : RefCell :: new ( None ) ,
646
+ compiled_auto_splitter : RwLock :: new ( None ) ,
647
647
}
648
648
}
649
649
@@ -656,7 +656,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
656
656
. compile ( & data)
657
657
. map_err ( |e| Error :: LoadFailed { source : e } ) ?;
658
658
self . instantiate ( & compiled_auto_splitter, timer) ?;
659
- * self . compiled_auto_splitter . borrow_mut ( ) = Some ( compiled_auto_splitter) ;
659
+ * self . compiled_auto_splitter . write ( ) . unwrap ( ) = Some ( compiled_auto_splitter) ;
660
660
Ok ( ( ) )
661
661
}
662
662
@@ -666,8 +666,9 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
666
666
compiled_auto_splitter : & CompiledAutoSplitter ,
667
667
timer : T ,
668
668
) -> Result < ( ) , Error > {
669
+ let settings_map = timer. get_timer ( ) . run ( ) . auto_splitter_settings_map_load ( ) ;
669
670
let auto_splitter = compiled_auto_splitter
670
- . instantiate ( Timer ( timer) , None , None )
671
+ . instantiate ( Timer ( timer) , settings_map , None )
671
672
. map_err ( |e| Error :: LoadFailed { source : e } ) ?;
672
673
673
674
self . auto_splitter
@@ -687,7 +688,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
687
688
/// Reloads the auto splitter without re-compiling.
688
689
pub fn reload ( & self , timer : T ) -> Result < ( ) , Error > {
689
690
self . unload ( ) ?;
690
- if let Some ( compiled_auto_splitter) = self . compiled_auto_splitter . borrow ( ) . as_ref ( ) {
691
+ if let Some ( compiled_auto_splitter) = self . compiled_auto_splitter . read ( ) . unwrap ( ) . as_ref ( ) {
691
692
self . instantiate ( compiled_auto_splitter, timer) ?;
692
693
}
693
694
Ok ( ( ) )
0 commit comments