File tree Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,11 @@ impl Executor for ImmediateUnpacker {
136
136
fn buffer_available ( & self , _len : usize ) -> bool {
137
137
true
138
138
}
139
+
140
+ #[ cfg( test) ]
141
+ fn buffer_used ( & self ) -> usize {
142
+ 0
143
+ }
139
144
}
140
145
141
146
/// The non-shared state for writing a file incrementally
Original file line number Diff line number Diff line change @@ -328,6 +328,10 @@ pub(crate) trait Executor {
328
328
329
329
/// Query the memory budget to see if a particular size buffer is available
330
330
fn buffer_available ( & self , len : usize ) -> bool ;
331
+
332
+ #[ cfg( test) ]
333
+ /// Query the memory budget to see how much of the buffer pool is in use
334
+ fn buffer_used ( & self ) -> usize ;
331
335
}
332
336
333
337
/// Trivial single threaded IO to be used from executors.
Original file line number Diff line number Diff line change @@ -48,13 +48,13 @@ fn test_incremental_file(io_threads: &str) -> Result<()> {
48
48
}
49
49
}
50
50
// sending a zero length chunk closes the file
51
- let mut chunk = io_executor. get_buffer ( 0 ) ;
51
+ let mut chunk = io_executor. get_buffer ( super :: IO_CHUNK_SIZE ) ;
52
52
chunk = chunk. finished ( ) ;
53
53
sender ( chunk) ;
54
54
loop {
55
55
for work in io_executor. completed ( ) . collect :: < Vec < _ > > ( ) {
56
56
match work {
57
- super :: CompletedIo :: Chunk ( _) => unreachable ! ( ) ,
57
+ super :: CompletedIo :: Chunk ( _) => { }
58
58
super :: CompletedIo :: Item ( _) => {
59
59
file_finished = true ;
60
60
}
@@ -69,6 +69,8 @@ fn test_incremental_file(io_threads: &str) -> Result<()> {
69
69
// no more work should be outstanding
70
70
unreachable ! ( ) ;
71
71
}
72
+
73
+ assert_eq ! ( io_executor. buffer_used( ) , 0 ) ;
72
74
Ok ( ( ) )
73
75
} ) ?;
74
76
// We should be able to read back the file
Original file line number Diff line number Diff line change @@ -350,6 +350,11 @@ impl<'a> Executor for Threaded<'a> {
350
350
let total_used = Threaded :: ram_highwater ( & self . vec_pools ) ;
351
351
total_used + size < self . ram_budget
352
352
}
353
+
354
+ #[ cfg( test) ]
355
+ fn buffer_used ( & self ) -> usize {
356
+ self . vec_pools . iter ( ) . map ( |( _, p) | * p. in_use . borrow ( ) ) . sum ( )
357
+ }
353
358
}
354
359
355
360
impl < ' a > Drop for Threaded < ' a > {
You can’t perform that action at this time.
0 commit comments