Ensuring Safe Concurrent Access to In-Memory Asset Balances
I'm looking for some advice on how to handle concurrent access to a value by key in memory.
I have a function
I need to ensure that while one part of the code is performing calculations and potentially updating the balance, the other part of the code waits to get the new balance to avoid race conditions.
I have a function
getAssetBalance(assetId: string): Effect<number> that retrieves the balance of a given asset. There are two different parts of my code that call getAssetBalance('USD') with the intention of subsequently modifying the balance.I need to ensure that while one part of the code is performing calculations and potentially updating the balance, the other part of the code waits to get the new balance to avoid race conditions.
