| 2518 | workerRuntime->registerTypeConverter(typeConverter.typeName, typeConverter.functionPath); |
| 2519 | } |
| 2520 | auto worker = makeShared<JavaScriptWorker>(strongSmallRef(this), workerRuntime, url); |
| 2521 | worker->postInit(); |
| 2522 | CHECK_CALL_CONTEXT(callContext); |
| 2523 | // worker->init(); // call outside of ctor so that shared_from_this() is available |
| 2524 | auto workerJSValue = callContext.getContext().newWrappedObject(worker, callContext.getExceptionTracker()); |
| 2525 | CHECK_CALL_CONTEXT(callContext); |
| 2526 | bindRuntimeFunction(callContext.getContext(), |
| 2527 | callContext.getExceptionTracker(), |
| 2528 | workerJSValue, |
| 2529 | "setOnMessage", |
| 2530 | &JavaScriptRuntime::workerSetOnMessage); |
| 2531 | CHECK_CALL_CONTEXT(callContext); |
| 2532 | bindRuntimeFunction(callContext.getContext(), |
| 2533 | callContext.getExceptionTracker(), |
| 2534 | workerJSValue, |
| 2535 | "postMessage", |
| 2536 | &JavaScriptRuntime::workerPostMessage); |
| 2537 | CHECK_CALL_CONTEXT(callContext); |
| 2538 | bindRuntimeFunction(callContext.getContext(), |
| 2539 | callContext.getExceptionTracker(), |
| 2540 | workerJSValue, |
| 2541 | "terminate", |
| 2542 | &JavaScriptRuntime::workerTerminate); |
| 2543 | CHECK_CALL_CONTEXT(callContext); |
| 2544 | { |
| 2545 | std::lock_guard<Mutex> guard(_jsWorkersMutex); |
| 2546 | _jsWorkers.emplace_back(weakRef(workerRuntime.get())); |
| 2547 | } |
| 2548 | // A worker created by a task already running when this runtime was marked joined _jsWorkers too late for |
| 2549 | // markWorkersHostTornDown(). Checked after the append, so either that pass saw it or this sees the flag. |
| 2550 | if (_hostTornDown) { |
| 2551 | workerRuntime->markHostTornDown(); |
| 2552 | } |
| 2553 | return workerJSValue; |
| 2554 | } |
| 2555 | |
| 2556 | JSValueRef JavaScriptRuntime::queueMicrotask(JSFunctionNativeCallContext& callContext) { |
| 2557 | callContext.getContext().enqueueMicrotask(callContext.getParameter(0), callContext.getExceptionTracker()); |
nothing calls this directly
no test coverage detected