Skip to content

Why do we need to lock? #558

@fade2black

Description

@fade2black

Hi! I don't understand why we need to wrap the core storage inside Arc<RwLock<>> (in MemStorage example). I do understand what Arc and RwLock do, locking and exclusive write access, etc, (so no need explanation), but why do we need an exclusive access? Doesn't each node have its own log storage? Or do nodes may access their log storage asynchronously from a several threads simultaneously?

#[derive(Clone, Default)]
pub struct MemStorage {
    core: Arc<RwLock<MemStorageCore>>,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionA question to be answered.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions