它可以配合使用Haskell的绿色线程的性能和易用性

它可以配合使用Haskell的绿色线程的性能和易用性

本文介绍了其中绿色线程库可用于C,它可以配合使用Haskell的绿色线程的性能和易用性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也习惯于依靠GHC的 forkIO 在Haskell编程时便携式轻量级线程。

I am well used to relying on GHC's forkIO for portable lightweight threads when programming in Haskell.

什么是等价的C库,可以提供相同的scalibility和易用性?

What are equivalent libraries for C that can provide the same scalibility and ease of use?

具体地说我需要至少以下两个功能的C-当量

Specifically I need C-equivalents of at least the following two functions.

forkIO     :: IO () -> IO ThreadId
killThread ::             ThreadId -> IO ()

我想我的应用程序,这将是不够的,如果线程只拦截行动,而不是被强制暂停,因为所有的线程阻塞的频率高的网络IO,我只使用拼接系统调用来要求Linux内核插槽之间推着数据。

I assume for my application, it would be enough if threads only switched on blocking operations rather than being forcefully suspended because all threads block highly frequently for network IO and I only use the splice system call to ask the Linux kernel to push data around between sockets.

更新

有图和表比较





  • GNU Pth
  • Protothreads
  • PM2 Parcel

有利于结果Protothreads。由于我没有用过,并还可能有其他图书馆,我很想从人谁使用了/开发了这样库的消息。

with results favoring Protothreads. As I have not used any and there may also be other libraries, I would love to hear from anyone who has used / developed such libraries.

推荐答案

libMill可能是你要搜索的内容:

libMill is probably what you're searching for: http://libmill.org/

它实现了用户级线程在转到郎通道的风格。

It implements user level threads in the Go-Lang channel style.

和它正在由超级智能马丁Sústrik,ZeroMQ 的创造者开发的。因此,它一定是好的☺

And it's being developed by the super smart Martin Sústrik, creator of ZeroMQ http://250bpm.com/. So it must be good ☺

这篇关于其中绿色线程库可用于C,它可以配合使用Haskell的绿色线程的性能和易用性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:50