Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top