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

Function fxWaitSharedChunkCallback

xs/sources/xsAtomics.c:901–934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

899
900#if mxThreads
901void fxWaitSharedChunkCallback(void* timer, void* refcon, txInteger refconSize)
902{
903 txSharedWaiter** address = (txSharedWaiter**)refcon;
904 txSharedWaiter* waiter = *address;
905 txSharedWaiter* link;
906 txMachine* the;
907 mxLockMutex(&gxSharedCluster->waiterMutex);
908 address = &(gxSharedCluster->first);
909 while ((link = *address)) {
910 if (link == waiter)
911 *address = link->next;
912 else
913 address = &(link->next);
914 }
915 mxUnlockMutex(&gxSharedCluster->waiterMutex);
916 the = waiter->the;
917 fxBeginHost(waiter->the);
918 mxTry(the) {
919 mxPushUndefined();
920 mxPush(waiter->resolve);
921 mxCall();
922 if (waiter->ok)
923 mxPushStringX("ok");
924 else
925 mxPushStringX("timed-out");
926 mxRunCount(1);
927 mxPop();
928 }
929 mxCatch(the) {
930 }
931 fxForget(the, &waiter->resolve);
932 fxEndHost(the);
933 c_free(waiter);
934}
935#endif
936
937txInteger fxWaitSharedChunk(txMachine* the, void* data, txNumber timeout, txSlot* resolveFunction)

Callers

nothing calls this directly

Calls 3

fxBeginHostFunction · 0.85
fxForgetFunction · 0.85
fxEndHostFunction · 0.85

Tested by

no test coverage detected