File tree 3 files changed +9
-7
lines changed
core/src/types/blocking_read
3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 18
18
use std:: collections:: Bound ;
19
19
use std:: ops:: Range ;
20
20
use std:: ops:: RangeBounds ;
21
+ use std:: sync:: Arc ;
21
22
22
23
use bytes:: Buf ;
23
24
use bytes:: BufMut ;
24
25
25
- use crate :: raw:: oio:: BlockingRead ;
26
26
use crate :: raw:: * ;
27
27
use crate :: * ;
28
28
29
29
/// BlockingReader is designed to read data from given path in an blocking
30
30
/// manner.
31
31
pub struct BlockingReader {
32
- pub ( crate ) inner : oio:: BlockingReader ,
32
+ pub ( crate ) inner : Arc < dyn oio:: BlockingRead > ,
33
33
}
34
34
35
35
impl BlockingReader {
@@ -43,7 +43,7 @@ impl BlockingReader {
43
43
pub ( crate ) fn create ( acc : Accessor , path : & str , op : OpRead ) -> crate :: Result < Self > {
44
44
let ( _, r) = acc. blocking_read ( path, op) ?;
45
45
46
- Ok ( BlockingReader { inner : r } )
46
+ Ok ( BlockingReader { inner : Arc :: new ( r ) } )
47
47
}
48
48
49
49
/// Read give range from reader into [`Buffer`].
Original file line number Diff line number Diff line change 16
16
// under the License.
17
17
18
18
use std:: io;
19
+ use std:: sync:: Arc ;
19
20
20
21
use bytes:: Buf ;
21
22
use bytes:: Bytes ;
@@ -28,7 +29,7 @@ use crate::raw::*;
28
29
///
29
30
/// StdIterator also implements [`Send`] and [`Sync`].
30
31
pub struct StdBytesIterator {
31
- inner : oio:: BlockingReader ,
32
+ inner : Arc < dyn oio:: BlockingRead > ,
32
33
offset : u64 ,
33
34
size : u64 ,
34
35
cap : usize ,
@@ -39,7 +40,7 @@ pub struct StdBytesIterator {
39
40
impl StdBytesIterator {
40
41
/// NOTE: don't allow users to create StdIterator directly.
41
42
#[ inline]
42
- pub ( crate ) fn new ( r : oio:: BlockingReader , range : std:: ops:: Range < u64 > ) -> Self {
43
+ pub ( crate ) fn new ( r : Arc < dyn oio:: BlockingRead > , range : std:: ops:: Range < u64 > ) -> Self {
43
44
StdBytesIterator {
44
45
inner : r,
45
46
offset : range. start ,
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use std::io::Read;
21
21
use std:: io:: Seek ;
22
22
use std:: io:: SeekFrom ;
23
23
use std:: ops:: Range ;
24
+ use std:: sync:: Arc ;
24
25
25
26
use bytes:: Buf ;
26
27
@@ -33,7 +34,7 @@ use crate::*;
33
34
///
34
35
/// StdReader also implements [`Send`] and [`Sync`].
35
36
pub struct StdReader {
36
- inner : oio:: BlockingReader ,
37
+ inner : Arc < dyn oio:: BlockingRead > ,
37
38
offset : u64 ,
38
39
size : u64 ,
39
40
cap : usize ,
@@ -45,7 +46,7 @@ pub struct StdReader {
45
46
impl StdReader {
46
47
/// NOTE: don't allow users to create StdReader directly.
47
48
#[ inline]
48
- pub ( super ) fn new ( r : oio:: BlockingReader , range : Range < u64 > ) -> Self {
49
+ pub ( super ) fn new ( r : Arc < dyn oio:: BlockingRead > , range : Range < u64 > ) -> Self {
49
50
StdReader {
50
51
inner : r,
51
52
offset : range. start ,
You can’t perform that action at this time.
0 commit comments