Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

micro TimeScheduler in Javascript?

24 views
Skip to first unread message

Jonas Thörnvall

unread,
Feb 5, 2018, 6:38:55 AM2/5/18
to
In timecritical applications it seem one often need some form of scheduler that takes a list of timings, to perform some sort of batch?
The jobs done and ready but waiting to be sent on certain time?

setSchedule(myFunction,myArraywithTimings);

I have a hard to even figure out if i should use setTimeout or setInterval to playup recorded events with their relative timing "in microseconds", or if there is other options?


Evertjan.

unread,
Feb 5, 2018, 8:21:43 AM2/5/18
to
Jonas <jonas.t...@gmail.com> wrote on 05
Feb 2018 in comp.lang.javascript:

> In timecritical applications it seem one often need some form of
> scheduler that takes a list of timings, to perform some sort of batch?
> The jobs done and ready but waiting to be sent on certain time?
>
> setSchedule(myFunction,myArraywithTimings);
>
> I have a hard to even figure out if i should use setTimeout

setTimeout fires only once, so that is whay you want, it seems.

> or setInterval

setInterval fires repeatedly

> to playup recorded events with their relative timing "in
> microseconds", or if there is other options?

You could poll a list ["schedule"] of tasks every so many miliseconds,
microseconds being outside the realm of practical scripting applications.



>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Julio Di Egidio

unread,
Feb 5, 2018, 8:55:34 AM2/5/18
to
On Monday, 5 February 2018 14:21:43 UTC+1, Evertjan. wrote:
> Jonas <jonas.t...@gmail.com> wrote on 05
> Feb 2018 in comp.lang.javascript:
<snip>
> > to playup recorded events with their relative timing "in
> > microseconds", or if there is other options?
>
> You could poll a list ["schedule"] of tasks every so many miliseconds,

Polling might be overkill, usually just fire the setTimeout: if you want a
schedule that persists across browser sessions, you'll have to record events,
and remove them when they have executed, still at session start you can
simply scan the list and just fire the timeouts again.

> microseconds being outside the realm of practical scripting applications.

Yep, and even milliseconds or even seconds: not only the timer is low
precision, when a timeout expires, the handler is marked for execution but
shall wait for its turn to run if there are other calls already running and
in the run queue. That said, indeed one hardly needs high precision timers
in the context of web scripting, or, more generally, user interfaces.

Julio
0 new messages