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

Function fx_setTimer

xs/tools/xst.c:854–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

852}
853
854void fx_setTimer(txMachine* the, txNumber interval, txBoolean repeat)
855{
856 txJob _job;
857 txJob* job;
858 txSharedTimer* timer;
859 if (c_isnan(interval) || (interval < 0))
860 interval = 0;
861 c_memset(&_job, 0, sizeof(txJob));
862 timer = fxScheduleSharedTimer(interval, (repeat) ? interval : 0, fx_callbackTimer, &_job, sizeof(txJob));
863 if (!timer)
864 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
865 job = (txJob*)&(timer->refcon[0]);
866 job->the = the;
867 fxNewHostObject(the, NULL);
868 mxPull(job->self);
869 job->function = *mxArgv(0);
870 if (mxArgc > 2)
871 job->argument = *mxArgv(2);
872 else
873 job->argument = mxUndefined;
874 fxSetHostData(the, &job->self, job);
875 fxSetHostHooks(the, &job->self, &gxTimerHooks);
876 fxRemember(the, &job->self);
877 fxAccess(the, &job->self);
878 *mxResult = the->scratch;
879}
880
881/* PLATFORM */
882

Callers 2

fx_setIntervalFunction · 0.85
fx_setTimeoutFunction · 0.85

Calls 7

fxScheduleSharedTimerFunction · 0.85
fxNewHostObjectFunction · 0.85
fxSetHostDataFunction · 0.85
fxSetHostHooksFunction · 0.85
fxRememberFunction · 0.85
fxAccessFunction · 0.85
fxAbortFunction · 0.70

Tested by

no test coverage detected