[−][src]Function kekbit::core::try_shm_reader
pub fn try_shm_reader(
root_path: &Path,
channel_id: u64,
duration_millis: u64,
tries: u64
) -> Result<ShmReader, ChannelError>
Tries multiple times to create a kekbit reader associated to a memory mapped channel.
This function will basically call shm_reader up to tries time unless
it succeeds. Between two tries the function will spin/sleep for a about duration_millis/tries
milliseconds so potentially could be blocking.
This should be the preferred method to create a reader when you are willing to wait until the channel is available.
Returns a ready to use reader which points to the beginning of a kekbit channel if succeeds, or the error returned by the last try if it fails.
Arguments
root_path
- The path to the folder where all the channels will be stored grouped by writer's id.writer_id
- The id of the writer which created the channel.channel_id
- The channel identifier.duration_millis
- How long it should try in millisecondstries
- How many times it will try during the given time duration
Errors
Various errors may occur if the operation fails.
Examples
use kekbit_core::shm::*; let writer_id = 1850; let channel_id = 42; let test_tmp_dir = tempdir::TempDir::new("kektest").unwrap(); let duration = 1000; let tries = 10; let reader = try_shm_reader(&test_tmp_dir.path(), channel_id, duration, tries).unwrap(); println!("{:?}", reader.header());