A promise which is resolved with the (eventually) returned
value by func
. Effectively, once the critical section has
been entered, Promise.resolve(func())
is returned.
Especially if func
returns a Thenable, by the semantics of
Promise.resolve
, this Thenable is adopted as the new Promise.
In other words, it is impossible to make
criticalSection.do(...)
resolve to a Promise, i.e.
await criticalSection.do(...)
be a Promise.
Create or get the object-bound critical section.
If no critical section is yet bound to the object, a new one is created and bound to that specific object. Critical sections bound to objects higher up in the prototype chain do not get inherited.
The object with which a new critical section bond should
be created if it does not exists yet.
object
must be a real object and not a primitive as per
the ECMAScript standard specification. Especially, the
following values are primitives (see also [MDN][1]):
A {@link TypeError} will be thrown if such a value is passed. (Note that there is no method to check for primitive values in ECMAScript, therefore, this method might not throw a {@link TypeError} or other errors for new primitive values introduced in yet-to-come ECMAScript versions.)
Generated using TypeDoc
Wait for the critical section to become available and execute a function.