Skip to content

Commit

Permalink
susge threads
Browse files Browse the repository at this point in the history
  • Loading branch information
khbsd committed May 23, 2024
1 parent f2be15c commit e851357
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion commands/debug2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const vscode = require('vscode');
const fs = require('fs');
const os = require('os');

const process = require('process');
const { Worker, isMainThread, BroadcastChannel, parentPort } = require('worker_threads')

const path = require('path');

const LSLIB_DLL = 'LSLib.dll';
Expand All @@ -17,8 +20,28 @@ const { FIND_FILES, getFormats } = require('../support_files/lslib_utils.js');

const debug2 = vscode.commands.registerCommand('bg3-mod-helper.debug2Command', async function () {
let halfCoreCount = os.availableParallelism() / 2;
let workerArray = [];
let bc = new BroadcastChannel("worker started");

if (isMainThread) {

for (let i = 0; i < halfCoreCount; i++) {
workerArray.push(new Worker(__filename));

workerArray[i].once('message', (message) => {
console.log(message);
});

workerArray[i].postMessage("Hello Worlds!");
}

// const vscode = require('vscode');
}
else {
parentPort.once('message', (message) => {
parentPort.postMessage(message);
})
}

});

module.exports = { debug2 }

0 comments on commit e851357

Please sign in to comment.