Struct ciruela::blocks::ThreadedBlockReader
[−]
[src]
pub struct ThreadedBlockReader { /* fields omitted */ }
A default threaded block reader
It starts 40 threads (by default) and reads every block requested from server. The number of threads is large to allow disk subsystem to reorder and optimize requests. Threads should be quite cheap in rust.
Note: no prefetching or caching blocks implemented because it's expected that servers request different blocks. Also, we don't know which blocks will be requested because in the average case most blocks are already on server because of similar images. Also, OS file cache is good enough.
Methods
impl ThreadedBlockReader
[src]
pub fn new() -> ThreadedBlockReader
[src]
Create a reader with default number of threads (40 at the moment)
pub fn new_num_threads(num: usize) -> ThreadedBlockReader
[src]
Create a reader with specified number of threads
pub fn register_dir<P: AsRef<Path>>(
&self,
dir: P,
index_data: &[u8]
) -> Result<(), DirError>
[src]
&self,
dir: P,
index_data: &[u8]
) -> Result<(), DirError>
Register a filesystem directory to respond to get_block request from
pub fn register_memory_blocks<T>(
&self,
hash_type: HashType,
block_size: u64,
data: T
) where
T: Into<Arc<[u8]>>,
[src]
&self,
hash_type: HashType,
block_size: u64,
data: T
) where
T: Into<Arc<[u8]>>,
Register some data that will be served from memory
Data will be provided by hashes, so isn't tied to any index or path
Trait Implementations
impl Debug for ThreadedBlockReader
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for ThreadedBlockReader
[src]
fn clone(&self) -> ThreadedBlockReader
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl GetBlock for ThreadedBlockReader
[src]
type Data = Vec<u8>
A block data returned Read more
type Error = ReadError
Error returned by future Read more
type Future = FutureBlock
Future returned by read_block
fn read_block(&self, hash: BlockHash, _hint: BlockHint) -> FutureBlock
[src]
Read block by hash