// wait_on_barrier_int
// Internal helper funtion providing blocking/non-blocking behavior in case a
// barrier has not reached
wait_on_barrier_int
Internal helper funtion providing blocking/non-blocking behavior in case a
barrier has not reached
wait_on_barrier_int Internal helper funtion providing blocking / non - blocking behavior in case a barrier has not reached
fn wait_on_barrier_int(&self, barrier_name: String, block: bool) -> Result<(), i32> {
        let mut dir = self.get_test_group_directory();
        let mut result;
        dir.push(&barrier_name);
        fs::create_dir_all(&dir)
            .unwrap_or_else(|_| panic!("Cannot create barrier dir for {}", &barrier_name));
        // Signal barrier
        let mut signal_file_name = dir.clone();
        signal_file_name.push(format!("Node_{}", self.node_id.get()));
        let file = File::create(signal_file_name.as_path());
        file.expect("Barrier Signal Failed");
        // Wait barrier
        loop {
            let mut signal_count = 0;
            let dir_content = fs::read_dir(&dir).expect("Barrier Wait Failed");
            for _entry in dir_content {
                signal_count += 1;
            }
            result = Err(-1);
            if signal_count >= self.num_replicas {
                result = Ok(());
                break;
            }
            if block {
                sleep(Duration::from_millis(5));
                continue;
            }
            break;
        }
        result
    }
fn wait_on_barrier_int ( & self , barrier_name : String , block : bool ) -> Result < ( ) , i32 > { let mut dir = self . get_test_group_directory ( ) ; let mut result ; dir . push ( & barrier_name ) ; fs :: create_dir_all ( & dir ) . unwrap_or_else ( | _ | panic ! ( " " barrier_name ) ) ; // Signal barrier let mut signal_file_name = dir . clone ( ) ; signal_file_name . push ( format ! ( " " self node_id get ( ) ) ) ; let file = File :: create ( signal_file_name . as_path ( ) ) ; file . expect ( " " ) ; // Wait barrier loop { let mut signal_count = 0 ; let dir_content = fs :: read_dir ( & dir ) . expect ( " " ) ; for _entry in dir_content { signal_count += 1 ; } result = Err ( - 1 ) ; if signal_count >= self . num_replicas { result = Ok ( ( ) ) ; break ; } if block { sleep ( Duration :: from_millis ( 5 ) ) ; continue ; } break ; } result }
wait_on_barrier_int
Internal helper funtion providing blocking/non-blocking behavior in case a
barrier has not reached
wait_on_barrier_int Internal helper funtion providing blocking / non - blocking behavior in case a barrier has not reached
&self
barrier_name
String
block
bool