xref: /third_party/node/test/addons/worker-buffer-callback/test-free-called.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/addons/worker-buffer-callback/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../../common');
31cb0ef41Sopenharmony_ciconst path = require('path');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads');
61cb0ef41Sopenharmony_ciconst binding = path.resolve(__dirname, `./build/${common.buildType}/binding`);
71cb0ef41Sopenharmony_ciconst { getFreeCallCount } = require(binding);
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci// Test that buffers allocated with a free callback through our APIs are
101cb0ef41Sopenharmony_ci// released when a Worker owning it exits.
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst w = new Worker(`require(${JSON.stringify(binding)})`, { eval: true });
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciassert.strictEqual(getFreeCallCount(), 0);
151cb0ef41Sopenharmony_ciw.on('exit', common.mustCall(() => {
161cb0ef41Sopenharmony_ci  assert.strictEqual(getFreeCallCount(), 1);
171cb0ef41Sopenharmony_ci}));
18

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