Skip to content

The Inventory mutex is too omnipresent #1744

@IntegratedQuantum

Description

@IntegratedQuantum

In #1739 I noticed that every block updates needs to lock the inventory mutex, since it needs to be locked when breaking a chest to remove the inventory.

Generally it would be nicer if this was less coupled, particularly it is problematic that we even get into the situation that the inventory mutex leaks into the update block function, this has a big risk of causing severe deadlocks in the future.
I'm not sure how this could be prevented though, since otherwise there is a risk that the inventory gets changed while breaking/placing a block (e.g. maybe the player collects something) which in turn changes the eligibility of breaking a block.

I think the right solution may be to avoid having a global mutex at all, maybe a per inventory mutex suffices? This does however make it more likely to deadlock for operations on multiple inventories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineexperimentala feature or idea that will require lots of experimentationquestionrefactorshuffle code around

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions