gpt4 book ai didi

multithreading - 常见的Lisp : Run function in the background

转载 作者:行者123 更新时间:2023-12-03 13:09:21 32 4
gpt4 key购买 nike

在Common Lisp中在后台运行函数的最佳方法是什么?具体来说,我正在打电话(trivial-shell:shell-command "<long and complicated command>"。此操作阻塞了大约10秒钟,但是我不在乎输出,只在乎副作用-所以我希望它在后台运行,以便程序流可以继续。我尝试将整个内容包装在sb-thread:make-thread中,但这似乎没有什么不同。

如果可能的话,我将避免陷入各种复杂的线程中。我在64位Gentoo Linux上运行SBCL 1.1.18。

最佳答案

我的小调查:看来唯一的解决方案是Renzo的答案:UIOP的launch-program函数。

否则,为了运行shell命令,有

  • UIOP的其他方法,例如run-program,是同步的。
  • [下 shell https://gitlab.common-lisp.net/qitab/inferior-shell]优先于琐碎的 shell 。它使用uiop:run-program,因此只能同步运行,
  • 关于multithreading - 常见的Lisp : Run function in the background,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41319173/

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