8

I read that Io language has Futures which can detect deadlock automatic. I know nothing about it and have seen some syntax. How does Io language detect deadlocks with this?

4

2 に答える 2

7

Io throws an exception when it encounters a deadlock.

ref: a post from I believe Steve Dekorte on lang.lightweight. Message pasted below:

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.

NB. The above post dates from 2003 so there have been some changes. Please see latest online Concurrency documentation for latest information.


Update - And from the online documentation it does say:

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.

于 2010-11-08T12:54:18.367 に答える
7

Each future knows which actor it is waiting on and each actor knows which future it is waiting on (if any) so Io justs walks this chain to see if the current actor is within it. If it is, there would be a deadlock. If not, there is not.

于 2010-12-28T16:05:12.957 に答える