xref: /third_party/node/test/parallel/test-worker-terminate-nested.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci// Check that a Worker that's running another Worker can be terminated.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst worker = new Worker(`
81cb0ef41Sopenharmony_ciconst { Worker, parentPort } = require('worker_threads');
91cb0ef41Sopenharmony_ciconst worker = new Worker('setInterval(() => {}, 10);', { eval: true });
101cb0ef41Sopenharmony_ciworker.on('online', () => {
111cb0ef41Sopenharmony_ci  parentPort.postMessage({});
121cb0ef41Sopenharmony_ci});
131cb0ef41Sopenharmony_ci`, { eval: true });
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciworker.on('message', common.mustCall(() => worker.terminate()));
16

Indexes created Thu Nov 07 10:32:03 CST 2024