Skip to content

Commit

Permalink
Remove init path dependency on ArrayBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Aug 21, 2019
1 parent 935526e commit ee548c3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/scheduler/src/SchedulerProfiling.js
Expand Up @@ -16,17 +16,21 @@ let runIdCounter: number = 0;
let mainThreadIdCounter: number = 0;

const profilingStateSize = 4;
export const sharedProfilingBuffer =
// $FlowFixMe Flow doesn't know about SharedArrayBuffer
typeof SharedArrayBuffer === 'function'
export const sharedProfilingBuffer = enableProfiling
? // $FlowFixMe Flow doesn't know about SharedArrayBuffer
typeof SharedArrayBuffer === 'function'
? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT)
: // $FlowFixMe Flow doesn't know about ArrayBuffer
new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT);

const profilingState = enableProfiling
? new Int32Array(sharedProfilingBuffer)
typeof ArrayBuffer === 'function'
? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT)
: null // Don't crash the init path on IE9
: null;

const profilingState =
enableProfiling && sharedProfilingBuffer !== null
? new Int32Array(sharedProfilingBuffer)
: null;

const PRIORITY = 0;
const CURRENT_TASK_ID = 1;
const CURRENT_RUN_ID = 2;
Expand Down

0 comments on commit ee548c3

Please sign in to comment.