@@ -53,7 +53,6 @@ impl NodeType for NonPV {
5353
5454pub fn start ( td : & mut ThreadData , report : Report , thread_count : usize ) {
5555 td. completed_depth = 0 ;
56- td. stopped = false ;
5756
5857 td. pv_table . clear ( 0 ) ;
5958 td. nnue . full_refresh ( & td. board ) ;
@@ -130,7 +129,7 @@ pub fn start(td: &mut ThreadData, report: Report, thread_count: usize) {
130129
131130 td. root_moves [ td. pv_index ..td. pv_end ] . sort_by_key ( |rm| std:: cmp:: Reverse ( rm. score ) ) ;
132131
133- if td. stopped {
132+ if td. shared . status . get ( ) == Status :: STOPPED {
134133 break ;
135134 }
136135
@@ -171,13 +170,15 @@ pub fn start(td: &mut ThreadData, report: Report, thread_count: usize) {
171170 }
172171 }
173172
174- if ! td. stopped {
173+ if td. shared . status . get ( ) != Status :: STOPPED {
175174 td. completed_depth = depth;
176175 }
177176
178177 if report == Report :: Full
179- && !( is_loss ( td. root_moves [ 0 ] . display_score ) && td. stopped )
180- && ( td. stopped || td. pv_index + 1 == td. multi_pv || td. shared . nodes . aggregate ( ) > 10_000_000 )
178+ && !( is_loss ( td. root_moves [ 0 ] . display_score ) && td. shared . status . get ( ) == Status :: STOPPED )
179+ && ( td. shared . status . get ( ) == Status :: STOPPED
180+ || td. pv_index + 1 == td. multi_pv
181+ || td. shared . nodes . aggregate ( ) > 10_000_000 )
181182 {
182183 td. print_uci_info ( depth) ;
183184 }
@@ -196,7 +197,10 @@ pub fn start(td: &mut ThreadData, report: Report, thread_count: usize) {
196197
197198 best_move_changes += td. best_move_changes ;
198199
199- if td. root_moves [ 0 ] . score != -Score :: INFINITE && is_loss ( td. root_moves [ 0 ] . score ) && td. stopped {
200+ if td. root_moves [ 0 ] . score != -Score :: INFINITE
201+ && is_loss ( td. root_moves [ 0 ] . score )
202+ && td. shared . status . get ( ) == Status :: STOPPED
203+ {
200204 if let Some ( pos) = td. root_moves . iter ( ) . position ( |rm| rm. mv == last_best_rootmove. mv ) {
201205 td. root_moves . remove ( pos) ;
202206 td. root_moves . insert ( 0 , last_best_rootmove. clone ( ) ) ;
@@ -205,7 +209,7 @@ pub fn start(td: &mut ThreadData, report: Report, thread_count: usize) {
205209 last_best_rootmove = td. root_moves [ 0 ] . clone ( ) ;
206210 }
207211
208- if td. stopped {
212+ if td. shared . status . get ( ) == Status :: STOPPED {
209213 break ;
210214 }
211215
@@ -239,7 +243,6 @@ pub fn start(td: &mut ThreadData, report: Report, thread_count: usize) {
239243 }
240244
241245 if td. shared . status . get ( ) == Status :: STOPPED {
242- td. stopped = true ;
243246 break ;
244247 }
245248 }
@@ -264,7 +267,7 @@ fn search<NODE: NodeType>(
264267 td. pv_table . clear ( ply as usize ) ;
265268 }
266269
267- if td. stopped {
270+ if td. shared . status . get ( ) == Status :: STOPPED {
268271 return Score :: ZERO ;
269272 }
270273
@@ -284,8 +287,8 @@ fn search<NODE: NodeType>(
284287 td. sel_depth = td. sel_depth . max ( ply as i32 ) ;
285288 }
286289
287- if td. time_manager . check_time ( td) {
288- td. stopped = true ;
290+ if td. id == 0 && td . time_manager . check_time ( td) {
291+ td. shared . status . set ( Status :: STOPPED ) ;
289292 return Score :: ZERO ;
290293 }
291294
@@ -553,7 +556,7 @@ fn search<NODE: NodeType>(
553556
554557 td. board . undo_null_move ( ) ;
555558
556- if td. stopped {
559+ if td. shared . status . get ( ) == Status :: STOPPED {
557560 return Score :: ZERO ;
558561 }
559562
@@ -566,7 +569,7 @@ fn search<NODE: NodeType>(
566569 let verified_score = search :: < NonPV > ( td, beta - 1 , beta, depth - r, false , ply) ;
567570 td. nmp_min_ply = 0 ;
568571
569- if td. stopped {
572+ if td. shared . status . get ( ) == Status :: STOPPED {
570573 return Score :: ZERO ;
571574 }
572575
@@ -617,7 +620,7 @@ fn search<NODE: NodeType>(
617620
618621 undo_move ( td, mv) ;
619622
620- if td. stopped {
623+ if td. shared . status . get ( ) == Status :: STOPPED {
621624 return Score :: ZERO ;
622625 }
623626
@@ -644,7 +647,7 @@ fn search<NODE: NodeType>(
644647 let score = search :: < NonPV > ( td, singular_beta - 1 , singular_beta, singular_depth, cut_node, ply) ;
645648 td. stack [ ply] . excluded = Move :: NULL ;
646649
647- if td. stopped {
650+ if td. shared . status . get ( ) == Status :: STOPPED {
648651 return Score :: ZERO ;
649652 }
650653
@@ -901,7 +904,7 @@ fn search<NODE: NodeType>(
901904
902905 undo_move ( td, mv) ;
903906
904- if td. stopped {
907+ if td. shared . status . get ( ) == Status :: STOPPED {
905908 return Score :: ZERO ;
906909 }
907910
@@ -1108,8 +1111,8 @@ fn qsearch<NODE: NodeType>(td: &mut ThreadData, mut alpha: i32, beta: i32, ply:
11081111 td. sel_depth = td. sel_depth . max ( ply as i32 ) ;
11091112 }
11101113
1111- if td. time_manager . check_time ( td) {
1112- td. stopped = true ;
1114+ if td. id == 0 && td . time_manager . check_time ( td) {
1115+ td. shared . status . set ( Status :: STOPPED ) ;
11131116 return Score :: ZERO ;
11141117 }
11151118
@@ -1223,7 +1226,7 @@ fn qsearch<NODE: NodeType>(td: &mut ThreadData, mut alpha: i32, beta: i32, ply:
12231226
12241227 undo_move ( td, mv) ;
12251228
1226- if td. stopped {
1229+ if td. shared . status . get ( ) == Status :: STOPPED {
12271230 return Score :: ZERO ;
12281231 }
12291232
0 commit comments