使用Go 1.2进行线程化的CGO

huangapple go评论91阅读模式
英文:

Threaded CGO using Go 1.2

问题

编辑:这个问题是无意义的。我误读了提交的日期,它已经包含在现有版本的Go工具中。谢谢,James!

看起来即将发布的Go(1.3)将允许非Go线程调用CGO回调函数。

我想知道人们通常是如何绕过这个限制的。

也就是说,我有一个第三方库,它自己创建线程,我想从这些线程中获取一些信息到Go代码中。

在代码的"C"一侧,是否有一种从C线程传递给Go线程的交接机制?是否有一种在不调用Go的情况下将消息放入队列的方法?还有其他的想法吗?

英文:

Edit: This question is moot. I misread the date on the commit, it is included in existing versions of the Go tools. Thanks, James!

It seems that the upcoming release of Go (1.3) will allow non-Go threads to call CGO callbacks.

I'm wondering what people have typically done to get around this restriction to date.

That is, I have a third party library that creates threads on its own, and I would like to get some information from those threads into the Go code.

Some sort of a handoff mechanism from a C thread to a Go thread on the "C" side of the code? Some way to get a message onto a queue without calling into Go? Other ideas?

答案1

得分: 0

你所突出显示的提交是去年2月的,早于Go 1.1版本的发布。它还引用了问题4435,标记为Go1.1

我不确定人们以前是如何绕过这个限制的(如果确实可能的话),但在过去两个发布版本的语言中,没有必要使用这种方法。我在我的一些项目中使用了这种能力,没有发生任何问题。

英文:

The commit you've highlighted was from February last year, which is from before the Go 1.1 release. It also references issue 4435, which is tagged Go1.1.

I'm not sure what people did to get around the restriction previously (if it was indeed possible), but for the last two released versions of the language, there has been no need to employ work arounds. I've made use of the ability in a number of my projects without incident.

huangapple
  • 本文由 发表于 2014年4月24日 02:26:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/23252387.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定