@@ -562,7 +562,7 @@ use livesplit_auto_splitting::{
562
562
Timer as AutoSplitTimer , TimerState ,
563
563
} ;
564
564
use 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 } ;
566
566
use tokio:: {
567
567
runtime,
568
568
sync:: watch,
@@ -598,7 +598,7 @@ pub struct Runtime<T> {
598
598
interrupt_receiver : watch:: Receiver < Option < InterruptHandle > > ,
599
599
auto_splitter : watch:: Sender < Option < AutoSplitter < Timer < T > > > > ,
600
600
runtime : livesplit_auto_splitting:: Runtime ,
601
- compiled_auto_splitter : RefCell < Option < CompiledAutoSplitter > > ,
601
+ compiled_auto_splitter : RwLock < Option < CompiledAutoSplitter > > ,
602
602
}
603
603
604
604
impl < T > Drop for Runtime < T > {
@@ -653,7 +653,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
653
653
auto_splitter : sender,
654
654
// TODO: unwrap?
655
655
runtime : livesplit_auto_splitting:: Runtime :: new ( Config :: default ( ) ) . unwrap ( ) ,
656
- compiled_auto_splitter : RefCell :: new ( None ) ,
656
+ compiled_auto_splitter : RwLock :: new ( None ) ,
657
657
}
658
658
}
659
659
@@ -666,7 +666,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
666
666
. compile ( & data)
667
667
. map_err ( |e| Error :: LoadFailed { source : e } ) ?;
668
668
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) ;
670
670
Ok ( ( ) )
671
671
}
672
672
@@ -676,8 +676,9 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
676
676
compiled_auto_splitter : & CompiledAutoSplitter ,
677
677
timer : T ,
678
678
) -> Result < ( ) , Error > {
679
+ let settings_map = timer. get_timer ( ) . run ( ) . auto_splitter_settings_map_load ( ) ;
679
680
let auto_splitter = compiled_auto_splitter
680
- . instantiate ( Timer ( timer) , None , None )
681
+ . instantiate ( Timer ( timer) , settings_map , None )
681
682
. map_err ( |e| Error :: LoadFailed { source : e } ) ?;
682
683
683
684
self . auto_splitter
@@ -697,7 +698,7 @@ impl<T: event::CommandSink + TimerQuery + Send + 'static> Runtime<T> {
697
698
/// Reloads the auto splitter without re-compiling.
698
699
pub fn reload ( & self , timer : T ) -> Result < ( ) , Error > {
699
700
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 ( ) {
701
702
self . instantiate ( compiled_auto_splitter, timer) ?;
702
703
}
703
704
Ok ( ( ) )
0 commit comments