@@ -562,7 +562,7 @@ use livesplit_auto_splitting::{
562562 Timer as AutoSplitTimer , TimerState ,
563563} ;
564564use snafu:: Snafu ;
565- use std:: { cell :: RefCell , fmt, fs, io, path:: PathBuf , thread, time:: Duration } ;
565+ use std:: { fmt, fs, io, path:: PathBuf , sync :: RwLock , thread, time:: Duration } ;
566566use tokio:: {
567567 runtime,
568568 sync:: watch,
@@ -598,7 +598,7 @@ pub struct Runtime<T> {
598598 interrupt_receiver : watch:: Receiver < Option < InterruptHandle > > ,
599599 auto_splitter : watch:: Sender < Option < AutoSplitter < Timer < T > > > > ,
600600 runtime : livesplit_auto_splitting:: Runtime ,
601- compiled_auto_splitter : RefCell < Option < CompiledAutoSplitter > > ,
601+ compiled_auto_splitter : RwLock < Option < CompiledAutoSplitter > > ,
602602}
603603
604604impl < T > Drop for Runtime < T > {
@@ -653,7 +653,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
653653 auto_splitter : sender,
654654 // TODO: unwrap?
655655 runtime : livesplit_auto_splitting:: Runtime :: new ( Config :: default ( ) ) . unwrap ( ) ,
656- compiled_auto_splitter : RefCell :: new ( None ) ,
656+ compiled_auto_splitter : RwLock :: new ( None ) ,
657657 }
658658 }
659659
@@ -666,7 +666,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
666666 . compile ( & data)
667667 . map_err ( |e| Error :: LoadFailed { source : e } ) ?;
668668 self . instantiate ( & compiled_auto_splitter, timer) ?;
669- * self . compiled_auto_splitter . borrow_mut ( ) = Some ( compiled_auto_splitter) ;
669+ * self . compiled_auto_splitter . write ( ) . unwrap ( ) = Some ( compiled_auto_splitter) ;
670670 Ok ( ( ) )
671671 }
672672
@@ -676,8 +676,9 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
676676 compiled_auto_splitter : & CompiledAutoSplitter ,
677677 timer : T ,
678678 ) -> Result < ( ) , Error > {
679+ let settings_map = timer. get_timer ( ) . run ( ) . auto_splitter_settings_map_load ( ) ;
679680 let auto_splitter = compiled_auto_splitter
680- . instantiate ( Timer ( timer) , None , None )
681+ . instantiate ( Timer ( timer) , settings_map , None )
681682 . map_err ( |e| Error :: LoadFailed { source : e } ) ?;
682683
683684 self . auto_splitter
@@ -697,7 +698,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
697698 /// Reloads the auto splitter without re-compiling.
698699 pub fn reload ( & self , timer : T ) -> Result < ( ) , Error > {
699700 self . unload ( ) ?;
700- if let Some ( compiled_auto_splitter) = self . compiled_auto_splitter . borrow ( ) . as_ref ( ) {
701+ if let Some ( compiled_auto_splitter) = self . compiled_auto_splitter . read ( ) . unwrap ( ) . as_ref ( ) {
701702 self . instantiate ( compiled_auto_splitter, timer) ?;
702703 }
703704 Ok ( ( ) )
0 commit comments