This repository was archived by the owner on Jun 10, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ pub struct Queues {
24
24
}
25
25
26
26
impl Queues {
27
+ #[ cfg( test) ]
28
+ pub fn contains ( & self , value : & Arc < ProcessControlBlock > ) -> bool {
29
+ self . waiting . contains ( value)
30
+ || self . normal_low . contains ( value)
31
+ || self . high . contains ( value)
32
+ || self . max . contains ( value)
33
+ }
34
+
27
35
#[ cfg( test) ]
28
36
pub fn run_queue_len ( & self , priority : Priority ) -> usize {
29
37
match priority {
@@ -117,6 +125,11 @@ impl Next {
117
125
pub struct Waiting ( HashSet < Arc < ProcessControlBlock > > ) ;
118
126
119
127
impl Waiting {
128
+ #[ cfg( test) ]
129
+ fn contains ( & self , value : & Arc < ProcessControlBlock > ) -> bool {
130
+ self . 0 . contains ( value)
131
+ }
132
+
120
133
fn get < Q : ?Sized > ( & self , value : & Q ) -> Option < & Arc < ProcessControlBlock > >
121
134
where
122
135
Arc < ProcessControlBlock > : Borrow < Q > ,
Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ use crate::run::Run;
13
13
pub struct Delayed ( VecDeque < DelayedProcess > ) ;
14
14
15
15
impl Delayed {
16
+ #[ cfg( test) ]
17
+ pub fn contains ( & self , value : & Arc < ProcessControlBlock > ) -> bool {
18
+ self . 0
19
+ . iter ( )
20
+ . any ( |delayed_process| & delayed_process. arc_process == value)
21
+ }
22
+
16
23
pub fn len ( & self ) -> usize {
17
24
self . 0 . len ( )
18
25
}
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ use crate::run::Run;
10
10
pub struct Immediate ( VecDeque < Arc < ProcessControlBlock > > ) ;
11
11
12
12
impl Immediate {
13
+ #[ cfg( test) ]
14
+ pub fn contains ( & self , value : & Arc < ProcessControlBlock > ) -> bool {
15
+ self . 0 . contains ( value)
16
+ }
17
+
13
18
pub fn len ( & self ) -> usize {
14
19
self . 0 . len ( )
15
20
}
Original file line number Diff line number Diff line change @@ -184,6 +184,11 @@ impl Scheduler {
184
184
self . run_queues . read ( ) . run_queue_len ( priority)
185
185
}
186
186
187
+ #[ cfg( test) ]
188
+ pub fn is_run_queued ( & self , value : & Arc < ProcessControlBlock > ) -> bool {
189
+ self . run_queues . read ( ) . contains ( value)
190
+ }
191
+
187
192
/// Returns `true` if `arc_process` was run; otherwise, `false`.
188
193
#[ must_use]
189
194
pub fn run_through ( & self , arc_process : & Arc < ProcessControlBlock > ) -> bool {
You can’t perform that action at this time.
0 commit comments