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

Function fxQueueJob

xs/sources/xsPromise.c:1225–1272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1223}
1224
1225void fxQueueJob(txMachine* the, txInteger count, txSlot* promise)
1226{
1227 txSlot* slot;
1228 txSlot* job;
1229 txSlot* item;
1230 txSlot* stack;
1231 txSlot** address;
1232
1233 if (promise) {
1234 txSlot* list = &mxUnhandledPromises;
1235 txSlot** address = &list->value.reference->next;
1236 while ((slot = *address)) {
1237 if (slot->value.weakRef.target == promise) {
1238 slot = slot->next;
1239 *address = slot->next;
1240 break;
1241 }
1242 slot = slot->next;
1243 address = &slot->next;
1244 }
1245#ifdef mxPromisePrint
1246 fprintf(stderr, "fxQueueJob %d\n", promise->next->ID);
1247#endif
1248#ifdef mxInstrument
1249 the->promisesSettledCount += 1;
1250#endif
1251 }
1252 if (mxPendingJobs.value.reference->next == NULL) {
1253 fxQueuePromiseJobs(the);
1254 }
1255 count += 4;
1256 item = stack = the->stack + count;
1257 slot = job = fxNewInstance(the);
1258 while (count > 0) {
1259 item--;
1260 slot = slot->next = fxNewSlot(the);
1261 slot->kind = item->kind;
1262 slot->value = item->value;
1263 count--;
1264 }
1265 address = &(mxPendingJobs.value.reference->next);
1266 while ((slot = *address))
1267 address = &(slot->next);
1268 slot = *address = fxNewSlot(the);
1269 slot->kind = XS_REFERENCE_KIND;
1270 slot->value.reference = job;
1271 the->stack = stack;
1272}
1273
1274void fxRunPromiseJobs(txMachine* the)
1275{

Callers 4

fxDebugCommandFunction · 0.85
fxPromiseThenFunction · 0.85
fxRejectPromiseFunction · 0.85
fxResolvePromiseFunction · 0.85

Calls 3

fxNewInstanceFunction · 0.85
fxNewSlotFunction · 0.85
fxQueuePromiseJobsFunction · 0.70

Tested by

no test coverage detected