Skip to content

feat: remove Mutex from Store#441

Merged
fmoletta merged 2 commits into
mainfrom
remove-mutex-leave-arc
Sep 20, 2024
Merged

feat: remove Mutex from Store#441
fmoletta merged 2 commits into
mainfrom
remove-mutex-leave-arc

Conversation

@fmoletta

@fmoletta fmoletta commented Sep 20, 2024

Copy link
Copy Markdown
Contributor

Motivation
Currently, our Store contains an Arc<Mutex<dyn StoreEngine>>, but the mutex is not really needed for the libmbdx backend, it is only needed for the InMemory one. This means we should be able to move the mutex into the in memory engine and leave the libmdbx mutex-free.
This PR proposes moving this mutex into the InMemory engine and changing the structure of Store to:

pub struct Store {
    engine:  Arc<dyn StoreEngine>
}

Description

  • Change Store.engine type from Arc<Mutex<dyn StoreEngine>> to E: StoreEngine,
  • Wrap in memory store engine in Arc<Mutex<>>
  • Rename implementations of StoreEngine to LibmdbxStoreEngine & InMemoryStoreEngine and expose them publicly
  • Add method new_temp for Store to be used in tests instead of creating and removing directories "by hand".

Closes #issue_number

@fmoletta fmoletta marked this pull request as ready for review September 20, 2024 15:42
@fmoletta fmoletta requested a review from a team as a code owner September 20, 2024 15:42

@mpaulucci mpaulucci left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mpaulucci mpaulucci changed the title feat: (Proposal) remove Mutex from Store feat: remove Mutex from Store Sep 20, 2024
@fmoletta fmoletta added this pull request to the merge queue Sep 20, 2024
Merged via the queue into main with commit 06d91c4 Sep 20, 2024
@fmoletta fmoletta deleted the remove-mutex-leave-arc branch September 20, 2024 17:18
github-merge-queue Bot pushed a commit that referenced this pull request Feb 7, 2025
This comment references a refactor that has been already implemented
#441
pedrobergamini pushed a commit to pedrobergamini/ethrex that referenced this pull request Aug 24, 2025
This comment references a refactor that has been already implemented
lambdaclass#441
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants