PledgeGuard

Struct PledgeGuard 

Source
pub struct PledgeGuard<'pledge, T> { /* private fields */ }

Implementations§

Source§

impl<'pledge, T> PledgeGuard<'pledge, T>
where T: GetUpdate,

Source

pub fn write(&self, u: T::U) -> MaybeClosed<()>

Source

pub fn write_multiples( &self, us: impl IntoIterator<Item = T::U>, ) -> MaybeClosed<()>

Examples found in repository?
examples/graph_bfs.rs (lines 22-25)
6fn main() {
7    let numbers: [_; 32] = std::array::from_fn(|i| i as u32);
8    let init = (0, 0, numbers.as_slice());
9    let synchronizer = Synchronizer::new(VecDeque::from([init]));
10    thread::scope(|scope| {
11        for _ in 0..thread::available_parallelism().unwrap().get() {
12            scope.spawn(|| {
13                for ((current, selected, remaining_slice), writer) in &synchronizer {
14                    use std::cmp::Ordering::*;
15                    match current.cmp(&TARGET) {
16                        Less => {
17                            let Some((next, remaining_slice)) = remaining_slice.split_first()
18                            else {
19                                continue;
20                            };
21                            writer
22                                .write_multiples([
23                                    (current + next, (selected << 1) + 1, remaining_slice),
24                                    (current, selected << 1, remaining_slice),
25                                ])
26                                .unwrap();
27                        }
28                        Equal => {
29                            dbg!(current, selected, remaining_slice);
30                            synchronizer.close();
31                        }
32                        Greater => (),
33                    }
34                }
35            });
36        }
37    })
38}

Trait Implementations§

Source§

impl<'pledge, T: Debug> Debug for PledgeGuard<'pledge, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'pledge, T> Drop for PledgeGuard<'pledge, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'pledge, T> Freeze for PledgeGuard<'pledge, T>

§

impl<'pledge, T> !RefUnwindSafe for PledgeGuard<'pledge, T>

§

impl<'pledge, T> Send for PledgeGuard<'pledge, T>
where T: Send,

§

impl<'pledge, T> Sync for PledgeGuard<'pledge, T>
where T: Send,

§

impl<'pledge, T> Unpin for PledgeGuard<'pledge, T>

§

impl<'pledge, T> !UnwindSafe for PledgeGuard<'pledge, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.