summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/src/thread_nextTick.ls
blob: 7ac3fe2658b66413c4165ab58814630cbfb0b754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function ThreadNextTick
    function next-tick (cb)
        thread._ntq.push cb
        return this
    function dispatch-next-ticks (l, p, err, _ntq)
        if l = (_ntq = thread._ntq).length
            p = err = 0
            try
                while true
                    _ntq[p]!
                    break unless ++p < l
            catch e
                thread._ntq = _ntq.slice ++p
                throw e
            return (thread._ntq = _ntq.slice p).length
        return 0
    thread._ntq = []
    thread.next-tick = next-tick
    return dispatch-next-ticks