KaiOS device plugin for recording memory allocations
Summary:
This adds basic plugin for recording memory allocations.
{F224005997}
Reviewed By: passy
Differential Revision: D18837209
fbshipit-source-id: aa29680b3a44c51135b760fe4ee76edc6d0ec109
This commit is contained in:
committed by
Facebook Github Bot
parent
cf512e5b83
commit
c7af0b53e6
@@ -15,17 +15,23 @@ export default function promiseTimeout<T>(
|
||||
timeoutMessage?: string,
|
||||
): Promise<T> {
|
||||
// Create a promise that rejects in <ms> milliseconds
|
||||
const timeout: Promise<T> = new Promise((resolve, reject) => {
|
||||
const id = setTimeout(() => {
|
||||
clearTimeout(id);
|
||||
reject(new Error(timeoutMessage || `Timed out in ${ms} ms.`));
|
||||
}, ms);
|
||||
const timeout = sleep(ms).then(() => {
|
||||
throw new Error(timeoutMessage || `Timed out in ${ms} ms.`);
|
||||
});
|
||||
|
||||
// Returns a race between our timeout and the passed in promise
|
||||
return Promise.race([promise, timeout]);
|
||||
}
|
||||
|
||||
export function sleep(ms: number): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
const id = setTimeout(() => {
|
||||
clearTimeout(id);
|
||||
resolve();
|
||||
}, ms);
|
||||
});
|
||||
}
|
||||
|
||||
export function showStatusUpdatesForPromise<T>(
|
||||
promise: Promise<T>,
|
||||
message: string,
|
||||
|
||||
Reference in New Issue
Block a user