Struct glock::GLockBuilder

source ·
pub struct GLockBuilder { /* private fields */ }
Expand description

A GLockBuilder can be used to construct nested GLocks. In Rust, inner structs are initialized before their outer container structs. In glock, parent lock kernels must be initialized before child lock kernels. To resolve this, a GLockBuilder can be used to initialize the parent lock kernel first, then accept the containing struct in build().

Example

use glock::{ GLock, GLockBuilder };

struct Parent {
    child1: GLock<u32>,
    child2: GLock<u32>,
}

let parent_lock = {

    let parent_lock_builder = GLockBuilder::new_root_builder();

    let parent = Parent {
        child1: parent_lock_builder.new_child(0u32).unwrap(),
        child2: parent_lock_builder.new_child(0u32).unwrap(),
    };

    parent_lock_builder.build(parent).unwrap()
};

Implementations§

Creates a new root GLock builder

Creates a builder for a GLock that is a child of the current GLock.

Creates a new Glock that is a child of the current GLock and protects the specified.

Builds the GLock object that protects the specified data.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.