Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在用 Haskell 编写服务器,我想在客户端断开连接后显式关闭它们。当我调用hClose时,线程将阻塞,直到客户端关闭它们的句柄。有没有办法让它在不阻塞的情况下关闭?
hClose
提前致谢!
当然,只需在另一个线程中运行它:
import Control.Concurrent (forkIO) forkIO (hClose handle)
正如 jozefg 所说,您可以使用更高级的解决方案,例如在 中找到的解决方案async,但我认为在这种情况下没有理由这样做。
async