Files
cocos4/scripts/pal-worker-fallback/compat.js
T
llsansun 2157fd176d Multithreading (#322)
* worker pool

* opt

* backup

* worker and worker backend

* worker fallback

* opt

* opt

* remove meta

* opt

* worker export

* testcase fix

* worker js template

* worker pal

* worker opt

* test

* Replace error messages with error codes

* Package size reduction

* Package size reduction

* revert

* Restore editor asset .meta files to the base branch state

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014HAtWwr4dy5azfpccweh1g

* bugfix

* Split into two features: Worker and Worker Pool

* worker option

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 16:35:14 +08:00

26 lines
992 B
JavaScript

// Compatibility only: real platform implementations remain in cocos-pal.
const reason = 'Installed PAL package has no worker module; using single-thread execution. '
+ 'Upgrade @cocos/engine-pal to enable platform workers.';
export function createWorkerBackend() {
return {
supportsStandardWorker: false,
scriptFailureHint: '',
resolveScriptWorker() {
return { backend: null, diagnosis: { ready: false, version: 0, reason }, warnOnFailure: false };
},
concurrencyLimit: 0,
hardwareConcurrency: 1,
supportsTransfer: false,
supportsSharedArrayBuffer: false,
supportsFunctionWorker: false,
capabilityReason: reason,
scriptFallback: null,
createFunctionWorker() { return null; },
createScriptWorker(path) {
throw new Error(`Cannot create worker "${path}": ${reason}`);
},
diagnose() { return { ready: false, version: 0, reason }; },
};
}