UNPKG

node-threads-pool

Version:

Node-Threads-Pool is a tool for creating thread pools in Node.js, making it easy to implement efficient parallel computing. With Node-Threads-Pool, you can easily create and manage multiple threads, allocate tasks to worker threads in the thread pool, and

23 lines (21 loc) 509 B
const pug = require('pug'); const os = require('os'); const {Eve, Thread, isMainThread} = require('../index'); async function threadFunc() { const options = {}; new Thread(_data => { const {template, data} = _data; options.data = data; return pug.renderFile(template, options); }); } if(!isMainThread) { threadFunc(); } else { const tp = new Eve(__filename, os.cpus().length); module.exports = async (template, data) => { return await tp.run({ template, data }); }; }