declare L = {NewLock} % not entirely sure if this is the right syntax
thread
lock L in
{Foo}
end
end
thread
lock L in
{Bar}
end
end
Even if the threads are created in order, there's no actual guarantee that the locks will be inquired in the same order the threads are created. Furthermore, there's a little bit more overhead because you're creating a thread for each message instead of running them all in the same thread.
It's probably more useful to think of active objects as pulling messages out of a message queue and processing them sequentially, because that's what they do.
Max
On 2/26/06,
Mark Engelberg <[EMAIL PROTECTED]> wrote:
CTM gives an implementation for, and examples using, "active objects"
which act like regular objects, but sit in their own thread and
process messages one at a time, in order received.
After reading the next chapter about locks, it seems to me that an
active object is essentially an object in which all methods are under
the same lock. For an alternative implementation of an active object,
you create a kind of object that wraps the whole message passing under
one lock, and executes each message in its own thread. Since
everything is under the same lock, messages will happen sequentially,
and thus you have similar (the same?) behavior as an asynchronous
active object.
Is my reasoning correct? Is message-passing concurrency essentially
an extreme version of "atomic action" concurrency in which the whole
object is under one lock? Are there any sigificant differences?
Thanks,
Mark
--
Be pretty if you are,
Be witty if you can,
But be cheerful if it kills you.
_________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
