Revamp the scheduler API
bordoley opened this issue · comments
The current api works but tends to depend upon closure, which can be a performance bottleneck. Instead we can redefine a scheduler as:
type t = {
schedule:
'state .
(('state => unit, 'state) => unit, 'state) => Disposable.t,
};
let immediate: t = {
schedule: (work, state) => {
let rec continuation = state => work(continuation, state);
work(continuation, state);
Disposable.disposed;
},
};
And define a delay scheduler as:
type t = {
schedule:
'state .
(~delay=float, ((~delay=float, 'state) => unit, 'state) => unit, 'state) => Disposable.t,
};
landed a big refactor. Still more tweaks to be made.