| 970 | } |
| 971 | |
| 972 | void fxRunLoop(txMachine* the) |
| 973 | { |
| 974 | txThread thread = mxCurrentThread(); |
| 975 | txNumber when; |
| 976 | txInteger count; |
| 977 | txSharedTimer* timer; |
| 978 | |
| 979 | for (;;) { |
| 980 | fxEndJob(the); |
| 981 | while (the->promiseJobs) { |
| 982 | while (the->promiseJobs) { |
| 983 | the->promiseJobs = 0; |
| 984 | fxRunPromiseJobs(the); |
| 985 | } |
| 986 | fxEndJob(the); |
| 987 | } |
| 988 | when = mxMonotonicNow(); |
| 989 | fxLockMutex(&(gxSharedTimers.mutex)); |
| 990 | count = 0; |
| 991 | timer = gxSharedTimers.first; |
| 992 | while (timer) { |
| 993 | if (timer->thread == thread) { |
| 994 | count++; |
| 995 | if (timer->when <= when) |
| 996 | break; // one timer at time to run promise jobs queued by the timer in the same "tick" |
| 997 | } |
| 998 | timer = timer->next; |
| 999 | } |
| 1000 | fxUnlockMutex(&(gxSharedTimers.mutex)); |
| 1001 | if (timer) { |
| 1002 | (timer->callback)(timer, timer->refcon, timer->refconSize); |
| 1003 | if (timer->interval == 0) |
| 1004 | fxUnscheduleSharedTimer(timer); |
| 1005 | else |
| 1006 | timer->when += timer->interval; |
| 1007 | continue; |
| 1008 | } |
| 1009 | if (count == 0) |
| 1010 | break; |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | void fxFulfillModuleFile(txMachine* the) |
| 1015 | { |
no test coverage detected