gpt4 book ai didi

multithreading - 如何在 perl 脚本中有条件地使用线程?

转载 作者:行者123 更新时间:2023-12-04 06:37:30 26 4
gpt4 key购买 nike

我有一个我开发的 perl 脚本,它在具有不同 perl 版本的主机上运行,​​有时用线程编译,有时不用。

我有一个

use if $Config{"useithreads"}, "threads";

我所有的线程特定代码都在类似的条件下。

但是,在编译阶段,perl 仍然在threads::all、threads::running 等问题上卡住。

我如何确定我的脚本在线程和非线程 perls 上运行?
 [ worr on worr-mn1 ] ( manage_usr_local_admin ) % perl -c acct_mgr_ng.pl
Bareword "threads::joinable" not allowed while "strict subs" in use at acct_mgr_ng.pl line 117.
BEGIN not safe after errors--compilation aborted at acct_mgr_ng.pl line 541.

最佳答案

当线程被加载时,perl 知道 threads::all (和 friend )是一个子程序调用,即使没有括号或 & ;由于线程可能不会被加载,只需用括号显式调用它:threads::all()

关于multithreading - 如何在 perl 脚本中有条件地使用线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17454318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com