-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
polishing and lots of comments. moved most of the worker thread stuff…
… into conversion_junction.js
- Loading branch information
Showing
3 changed files
with
84 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
commands/conversion_worker.js → support_files/conversion_worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
const { CREATE_LOGGER, raiseError, raiseInfo } = require('../support_files/log_utils.js'); | ||
const { CREATE_LOGGER, raiseError, raiseInfo } = require('./log_utils.js'); | ||
const bg3mh_logger = CREATE_LOGGER(); | ||
const { parentPort, workerData } = require('node:worker_threads'); | ||
const path = require('node:path'); | ||
const fs = require('node:fs'); | ||
|
||
|
||
const { convert } = require('../support_files/conversion_junction.js') | ||
const { convert } = require('./conversion_junction.js') | ||
|
||
function taskIntake() { | ||
// console.log(workerData.task) | ||
// basic array or file handling stuff | ||
if (Array.isArray(workerData.task)) { | ||
for (let i = 0; i < workerData.task.length; i++) { | ||
|
||
try { | ||
raiseInfo(`converting ${workerData.task[i]}`); | ||
// convert(workerData.task[i]); | ||
convert(workerData.task[i]); | ||
} catch (Error) { | ||
raiseError(`converting ${workerData.task[i]}\n failed with error ${Error}`); | ||
} | ||
} | ||
} else if (typeof(workerData.task) == 'string') { | ||
try { | ||
raiseInfo(`converting ${workerData.task}`); | ||
// convert(workerData.task); | ||
convert(workerData.task); | ||
} catch (Error) { | ||
raiseError(`converting ${workerData.task}\n failed with error ${Error}`); | ||
} | ||
} | ||
|
||
// let the main thread know you're done | ||
parentPort.postMessage(`worker ${workerData.workerId} done.`); | ||
} | ||
|
||
// start it up babyyyyy | ||
taskIntake(); |