我读到 Io 语言有 Futures
可以自动检测死锁。我对此一无所知,也见过一些语法。 Io 语言如何用这个检测死锁?
最佳答案
Io 在遇到死锁时抛出异常。
引用: post来自我相信 Steve Dekorte在 lang.lightweight .留言粘贴如下:
Io has continuations in the form of asynchronous messages and futures. Example:
aFuture = obj @foo
// the @ means "perform message foo asynchronously"
// that is, in a light weight thread owned by obj
// The aFuture's value ivar is set with the result
result = aFuture value
// This causes the current light weight thread to pause
// until the aFuture's vale is set.
// So this is effectively a continuation.
// another option is:
obj @(foo) sendResultTo(target, "foobar")
// which is more like the callcc style
The interesting thing about this style of use is that no one seems to find it difficult to understand. Also, Io uses futures to do automatic deadlock detection. When a deadlock would happen, it raises an exception instead of allowing it.
注意。上面的帖子是 2003 年的,所以有一些变化。最新在线请看
Concurrency
最新信息的文档。更新 - 来自 online documentation它确实说:
Auto Deadlock Detection
An advantage of using futures is that when a future requires a wait, it will check to see if pausing to wait for the result would cause a deadlock and if so, avoid the deadlock and raise an exception. It performs this check by traversing the list of connected futures.
关于concurrency - Io 语言如何自动检测死锁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4121166/