cherry-pick Cooperate (#985)

* cooperate pause

* fix math

* update lastPause before pausing

* faster cooperation

Co-authored-by: Peli de Halleux <peli@DESKTOP-5B7QRAM.corp.microsoft.com>
This commit is contained in:
Peli de Halleux
2020-08-21 06:06:59 +02:00
committed by Peli de Halleux
parent 1db61720fc
commit f0821f8d6c
5 changed files with 19 additions and 10 deletions

11
libs/core/cooperate.ts Normal file
View File

@ -0,0 +1,11 @@
namespace control {
let lastPause = 0;
const COOPERATION_INTERVAL = 20
export function cooperate() {
const now = control.millis()
if (now - lastPause > COOPERATION_INTERVAL) {
lastPause = now
pause(1)
}
}
}