BarrierWaitResult — 배리어 대기 결과
BarrierWaitResult — 배리어 대기 결과
BarrierWaitResult는 Barrier::wait()가 반환하는 결과 타입이에요. 배리어의 모든 스레드가 모였을 때 반환돼요.
출처: Rust 공식 문서
본문
pub struct BarrierWaitResult(/* private fields */);
예시
use std::sync::Barrier;
let barrier = Barrier::new(1);
let barrier_wait_result = barrier.wait();
주요 메서드
pub fn is_leader(&self) -> bool
is_leader는 이 스레드가 Barrier::wait() 호출의 "리더 스레드"인지 여부를 반환해요. 여러 스레드 중 정확히 하나만 true를 받고, 나머지는 모두 false를 받아요.
use std::sync::Barrier;
let barrier = Barrier::new(1);
let barrier_wait_result = barrier.wait();
println!("{:?}", barrier_wait_result.is_leader());
이 타입은 Debug 트레잇을 구현해요.