When two different execution contexts that share a closure variable are entered in parallel, one will acquire a lock
means that a listener will lock on parent closure right at the start of the function till its end? Or it will lock only from the time of identifier resolution for count to finishing its value reading?
How does it work? If event listeners run on parallel threads, there will be a race condition in the increment without synchronization.
Hi! Concurrent access to variables does not corrupt them or cause a race condition. All variables behave atomically in Nexus.
Read more here: nexusjs.com/architecture/
So, in this particular example
means that a listener will lock on parent closure right at the start of the function till its end? Or it will lock only from the time of identifier resolution for
count
to finishing its value reading?It will only lock upon access to the variable and then it will release the lock as soon as it is done.
Thank you.
You’re welcome :)