-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary wakeups and use requestIdleCallback
- Loading branch information
1 parent
9b2587b
commit 3b1543d
Showing
7 changed files
with
78 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
(library | ||
(name eio_browser) | ||
(public_name eio_browser) | ||
(foreign_stubs | ||
(language c) | ||
(names stubs)) | ||
(js_of_ocaml (javascript_files runtime.js)) | ||
(libraries eio brr)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// A shim for safari: https://developer.chrome.com/blog/using-requestidlecallback/ | ||
|
||
// Provides: requestIdleCallbackShim | ||
function requestIdleCallbackShim (cb) { | ||
if (window.requestIdleCallback) { | ||
window.requestIdleCallback(cb) | ||
} else { | ||
var start = Date.now(); | ||
globalThis.setTimeout(function () { | ||
cb({ | ||
didTimeout: false, | ||
timeRemaining: function () { | ||
return Math.max(0, 50 - (Date.now() - start)); | ||
} | ||
}); | ||
}, 1); | ||
} | ||
} | ||
|
||
// Provides: cancelIdleCallbackShim | ||
function cancelIdleCallbackShim (id) { | ||
if (window.cancelIdleCallback) { | ||
window.cancelIdleCallback(id); | ||
} else { | ||
globalThis.clearTimeout(id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
void requestIdleCallbackShim () { fprintf(stderr, "Unimplemented Javascript primitive requestIdleCallbackShim!\n"); exit(1); } | ||
void cancelIdleCallbackShim () { fprintf(stderr, "Unimplemented Javascript primitive cancelIdleCallbackShim!\n"); exit(1); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters