MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_Atomics_waitAsync

Function fx_Atomics_waitAsync

xs/sources/xsAtomics.c:569–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567
568#if mxECMAScript2024
569void fx_Atomics_waitAsync(txMachine* the)
570{
571 mxAtomicsDeclarations(1, 1, 0);
572 txNumber timeout;
573 txInteger result;
574 txSlot* slot;
575 fxPushAtomicsValue(the, 2, dispatch->value.typedArray.dispatch->constructorID);
576 timeout = (mxArgc > 3) ? fxToNumber(the, mxArgv(3)) : C_NAN;
577 if (c_isnan(timeout))
578 timeout = C_INFINITY;
579 else if (timeout < 0)
580 timeout = 0;
581 result = (*dispatch->value.typedArray.atomics->wait)(the, host, offset, the->stack, timeout);
582
583 mxPush(mxObjectPrototype);
584 slot = fxLastProperty(the, fxNewObjectInstance(the));
585 slot = fxNextBooleanProperty(the, slot, (result <= 0) ? 0 : 1, mxID(_async), XS_NO_FLAG);
586 if (result < 0)
587 fxNextStringXProperty(the, slot, "not-equal", mxID(_value), XS_NO_FLAG);
588 else if (result == 0)
589 fxNextStringXProperty(the, slot, "timed-out", mxID(_value), XS_NO_FLAG);
590 else {
591 txSlot* resolveFunction;
592 txSlot* rejectFunction;
593 mxTemporary(resolveFunction);
594 mxTemporary(rejectFunction);
595 mxPush(mxPromiseConstructor);
596 fxNewPromiseCapability(the, resolveFunction, rejectFunction);
597 fxNextSlotProperty(the, slot, the->stack, mxID(_value), XS_NO_FLAG);
598 mxPop(); // promise
599 fxWaitSharedChunk(the, (txByte*)host->value.host.data + offset, timeout, resolveFunction);
600 mxPop(); // rejectFunction
601 mxPop(); // resolveFunction
602 }
603 mxPullSlot(mxResult);
604}
605#endif
606
607void fx_Atomics_xor(txMachine* the)

Callers

nothing calls this directly

Calls 9

fxPushAtomicsValueFunction · 0.85
fxToNumberFunction · 0.85
fxLastPropertyFunction · 0.85
fxNewObjectInstanceFunction · 0.85
fxNextBooleanPropertyFunction · 0.85
fxNextStringXPropertyFunction · 0.85
fxNewPromiseCapabilityFunction · 0.85
fxNextSlotPropertyFunction · 0.85
fxWaitSharedChunkFunction · 0.85

Tested by

no test coverage detected