如何使perl线程而不复制所有变量? [英] How to make perl thread without copying all variables?

查看:41
本文介绍了如何使perl线程而不复制所有变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个perl程序,在其中使用某种形式的并行性确实会有所帮助.

I have one perl program, where using some form of parallelism would really be helpful.

但是,我在变量中有很多数据,在程序的那部分我根本不需要 .

However, I have quite a lot of data in variables, that I don't need at all at that part of the program.

如果我使用perl线程,则每次创建新线程时,它都会复制 all 个变量.就我而言,这很痛苦.

If I use perl threads, it copies all variables every time I create a new thread. In my case, that hurts a lot.

在不复制的情况下,我应该使用什么来制作新线程?还是有一些更好的线程实现而不复制所有内容?

What should I use to make a new thread without the copying? Or are there some better thread implementations, that don't copy everything?

推荐答案

像语法一样,易于使用线程但不是全部都容易?使用令人惊叹的叉子模块!它使用fork和IPC实现线程接口,从而使子进程之间的数据共享变得容易.

Like the syntax an ease of threads but not all the fat? Use the amazing forks module! It implements the threads interface using fork and IPC making it easy to share data between child processes.

这篇关于如何使perl线程而不复制所有变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆