@@ -39,7 +39,7 @@ pub(crate) struct CoreSplit<'a> {
3939}
4040
4141#[ derive( Default ) ]
42- pub struct Core {
42+ pub ( crate ) struct Core {
4343 tasks : TaskMap ,
4444 workers : WorkerMap ,
4545 resource_map : GlobalResourceMapping ,
@@ -109,12 +109,12 @@ impl Core {
109109 }
110110 }
111111
112- pub fn new_worker_id ( & mut self ) -> WorkerId {
112+ pub ( crate ) fn new_worker_id ( & mut self ) -> WorkerId {
113113 self . worker_id_counter += 1 ;
114114 WorkerId :: new ( self . worker_id_counter )
115115 }
116116
117- pub fn worker_counter ( & self ) -> u32 {
117+ pub ( crate ) fn worker_counter ( & self ) -> u32 {
118118 self . worker_id_counter
119119 }
120120
@@ -175,26 +175,22 @@ impl Core {
175175 }
176176
177177 #[ inline]
178- pub fn get_worker_by_id ( & self , id : WorkerId ) -> Option < & Worker > {
179- self . workers . get ( & id)
180- }
181-
182- #[ inline]
183- pub fn get_worker_by_id_or_panic ( & self , id : WorkerId ) -> & Worker {
178+ pub fn get_worker ( & self , id : WorkerId ) -> & Worker {
184179 self . workers . get ( & id) . unwrap_or_else ( || {
185180 panic ! ( "Asking for invalid worker id={id}" ) ;
186181 } )
187182 }
188183
189184 #[ inline]
190- pub fn get_worker_mut_by_id_or_panic ( & mut self , id : WorkerId ) -> & mut Worker {
185+ #[ cfg( test) ]
186+ pub fn get_worker_mut ( & mut self , id : WorkerId ) -> & mut Worker {
191187 self . workers . get_mut ( & id) . unwrap_or_else ( || {
192188 panic ! ( "Asking for invalid worker id={id}" ) ;
193189 } )
194190 }
195191
196192 #[ inline]
197- pub fn get_worker_mut ( & mut self , id : WorkerId ) -> Option < & mut Worker > {
193+ pub fn find_worker_mut ( & mut self , id : WorkerId ) -> Option < & mut Worker > {
198194 self . workers . get_mut ( & id)
199195 }
200196
@@ -203,21 +199,11 @@ impl Core {
203199 self . workers . values ( )
204200 }
205201
206- #[ inline]
207- pub fn get_workers_mut ( & mut self ) -> impl Iterator < Item = & mut Worker > {
208- self . workers . values_mut ( )
209- }
210-
211202 #[ inline]
212203 pub fn get_worker_map ( & self ) -> & WorkerMap {
213204 & self . workers
214205 }
215206
216- #[ inline]
217- pub fn has_workers ( & self ) -> bool {
218- !self . workers . is_empty ( )
219- }
220-
221207 pub fn add_task ( & mut self , task : Task , retracted : & mut Vec < TaskId > ) {
222208 if task. is_ready ( ) {
223209 self . task_queues . add_ready_task ( & task, retracted) ;
@@ -260,11 +246,6 @@ impl Core {
260246 & self . tasks
261247 }
262248
263- #[ inline]
264- pub fn task_map_mut ( & mut self ) -> & mut TaskMap {
265- & mut self . tasks
266- }
267-
268249 #[ inline]
269250 pub fn get_task ( & self , task_id : TaskId ) -> & Task {
270251 self . tasks . get_task ( task_id)
@@ -453,13 +434,6 @@ impl Core {
453434 self . resource_map . get_or_create_resource_id ( name)
454435 }
455436
456- pub fn convert_client_resource_rq (
457- & mut self ,
458- resources : & crate :: gateway:: ResourceRequestVariants ,
459- ) -> ResourceRequestVariants {
460- self . resource_map . convert_client_resource_rq ( resources)
461- }
462-
463437 #[ inline]
464438 pub fn resource_map ( & self ) -> & GlobalResourceMapping {
465439 & self . resource_map
@@ -511,13 +485,10 @@ impl Core {
511485mod tests {
512486 use crate :: internal:: server:: core:: Core ;
513487 use crate :: internal:: server:: task:: Task ;
514-
515- use crate :: internal:: server:: worker:: Worker ;
516- use crate :: internal:: server:: workergroup:: WorkerGroup ;
517488
518-
489+ use crate :: internal :: server :: workergroup :: WorkerGroup ;
519490
520- use crate :: { TaskId , WorkerId } ;
491+ use crate :: TaskId ;
521492
522493 impl Core {
523494 pub fn worker_group ( & self , group_name : & str ) -> Option < & WorkerGroup > {
@@ -532,18 +503,6 @@ mod tests {
532503 }
533504 }
534505
535- pub fn assert_worker_condition < F : Fn ( & Worker ) -> bool > (
536- & self ,
537- worker_ids : & [ WorkerId ] ,
538- op : F ,
539- ) {
540- for worker_id in worker_ids {
541- if !op ( self . get_worker_by_id_or_panic ( * worker_id) ) {
542- panic ! ( "Worker {worker_id} does not satisfy the condition" ) ;
543- }
544- }
545- }
546-
547506 pub fn assert_waiting ( & self , task_ids : & [ TaskId ] ) {
548507 self . assert_task_condition ( task_ids, |t| t. is_waiting ( ) ) ;
549508 }
0 commit comments