concurrency - Io 语言如何自动检测死锁?

标签 concurrency deadlock iolanguage

我读到 Io 语言有 Futures 可以自动检测死锁。我对此一无所知,也见过一些语法。 Io 语言如何用这个检测死锁?

最佳答案

Io 在遇到死锁时抛出异常。

引用: post来自我相信 Steve Dekortelang.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/

相关文章:

mysql - 如何避免 MySQL 'Deadlock found when trying to get lock; try restarting transaction'

c# - 为什么 ASP.NET Core Web API 中没有出现这种死锁?

java - 如何检测 Netbeans 中的 Java 应用程序锁定?

import - 如何导入 Io 语言的插件?

c - pthread_join() 和 pthread_exit()

python - 如何使用python在多台服务器上执行命令

java - 奇怪的错误 - 如何暂停 java 程序?

java - 理解发生在关系之前

scope - Io 中的作用域是如何工作的?

iolanguage - 如何在交互式 Io 解释器中输入多行方法?