I don't know if there is a straight link to async-mutex but i am actually doing this thing:
// listening for events
provider.pairContract.on('Sync', async (...dexReserves) => {
...
// No exclusive code here, can be // if multiple events are triggered really quickly
...
// Here we should be able to be notified from the thread running the exclusive code
var release = await mutex.acquire();
// Exclusive code - may take several seconds, so many threads will wait for the mutex to be unlocked
release();
}
What i'm trying to do here is that i would like to communicate a value from the thread running the exclusive code, to the waiting threads waiting for mutex to be unlocked. Why ? because conditions of execution of the waiting threads may vary depending of what happens in the thread having the lock.
I was thinking using an EventEmmiter, but i was wondering if may be there is a way to communicate a variable from a synchronized portion of code thanks to async-mutex ?
Hello folks,
I don't know if there is a straight link to
async-mutex
but i am actually doing this thing:What i'm trying to do here is that i would like to communicate a value from the thread running the exclusive code, to the waiting threads waiting for mutex to be unlocked. Why ? because conditions of execution of the waiting threads may vary depending of what happens in the thread having the lock.
I was thinking using an EventEmmiter, but i was wondering if may be there is a way to communicate a variable from a synchronized portion of code thanks to async-mutex ?
Thanks a lot and GG for this lib ! Cheers,