Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 428x 3424x 3424x 428x 428x 428x 428x 428x 428x 428x | import { setOptions } from './imageLoader/internal/index'; import type { LoaderOptions } from './types'; import registerLoaders from './imageLoader/registerLoaders'; import { getWebWorkerManager } from '@cornerstonejs/core'; const workerFn = () => { const instance = new Worker( new URL('./decodeImageFrameWorker.js', import.meta.url), { type: 'module' } ); return instance; }; function init(options: LoaderOptions = {}): void { // setting options should happen first, since we use the options in the // cornerstone set // DO NOT CHANGE THE ORDER OF THESE TWO LINES! setOptions(options); registerLoaders(); const workerManager = getWebWorkerManager(); const maxWorkers = options?.maxWebWorkers || getReasonableWorkerCount(); workerManager.registerWorker('dicomImageLoader', workerFn, { maxWorkerInstances: maxWorkers, }); } function getReasonableWorkerCount(): number { Eif (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) { // Use half of the available cores, but at least 1 return Math.max(1, Math.floor(navigator.hardwareConcurrency / 2)); } // Default to 1 if we can't determine the number of cores return 1; } export default init; |