将F.worker2与Total.js一起使用

时间:2017-05-28 19:08:00

标签: total.js

我想在F.worker2中使用一些args。 你有一些例子吗? 如何将F.worker2与Total.js一起使用?

谢谢

1 个答案:

答案 0 :(得分:3)

只需发送其他参数https://docs.totaljs.com/latest/en.html#api~Framework~F.worker2或发送消息:

var worker = F.worker2();

// Worker has to have defined "message" event:
// process.on('message', function(msg) { console.log('Data from parent', msg); });

setImmediate(function() {
   worker.send({ simple: 'value' });
});

https://nodejs.org/dist/latest-v7.x/docs/api/child_process.html#child_process_child_send_message_sendhandle_options_callback