Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid mutex in ExecutionStatePool for Wasm compatibility #118

Merged
merged 3 commits into from
Dec 17, 2020
Merged

Conversation

yperbasis
Copy link
Member

@yperbasis yperbasis commented Dec 16, 2020

Issue #111


std::unique_ptr<evmone::execution_state> ExecutionStatePool::acquire() noexcept {
std::lock_guard lock{mutex_};
if (pool_.empty()) {
return std::make_unique<evmone::execution_state>();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not in this PR but why acquire from pool_ doesnt' use move semantic (like as in release method) ?

I mean this

    std::unique_ptr<evmone::execution_state> obj{pool_.top().release()};
    pool_.pop();
    return obj;

could be changed to this

    auto obj{std::move(pool_.top())};
    pool_.pop();
    return obj;

Copy link
Member Author

Choose a reason for hiding this comment

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

Not in this PR but why acquire from pool_ doesnt' use move semantic (like as in release method) ?

I mean this

    std::unique_ptr<evmone::execution_state> obj{pool_.top().release()};
    pool_.pop();
    return obj;

could be changed to this

    auto obj{std::move(pool_.top())};
    pool_.pop();
    return obj;

This should also probably work, I'm just not that familiar with move semantics.

@yperbasis yperbasis merged commit 2b1e103 into master Dec 17, 2020
@yperbasis yperbasis deleted the no-mutex branch December 18, 2020 14:40
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