at:tutorial:actors
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:actors [2007/04/01 11:04] – created tvcutsem | at:tutorial:actors [2007/04/01 11:46] – added tvcutsem | ||
---|---|---|---|
Line 1: | Line 1: | ||
< | < | ||
- | ==== Concurrent Programming with Actors ==== | + | ===== Concurrent Programming with Actors ===== |
+ | |||
+ | Concurrency is an integral part of the AmbientTalk programming language. Rather than relying on [[wp> | ||
+ | |||
+ | === Threads vs Actors === | ||
+ | |||
+ | In traditional programming languages, the control flow of a concurrent program is divided over a number of threads. Each thread operates concurrently and control can switch from one thread to another non-deterministically. If two threads have access to the same data (objects), they might cause erroneous behaviour (so-called //race conditions// | ||
+ | |||
+ | The advantages of the thread-based model are that the model itself is easy to understand, it is efficiently implementable and it can be used to create very fine-grained synchronization (e.g. [[wp> | ||
+ | |||
+ | The original [[wp> | ||
+ | |||
+ | Generally speaking, an active object is an object that encapsulates its own thread of control. An active object also has a message queue or mailbox from which it processes incoming messages. Each message is processed sequentially. An active object responds to an incoming message by invoking the method corresponding to the message. The method is executed by the active object' | ||
=== Actors and Far References === | === Actors and Far References === | ||
+ | |||
+ | In AmbientTalk, | ||
+ | |||
+ | When an actor is created, it hosts a single object which is said to be the actor' | ||
+ | |||
+ | < | ||
+ | def a := actor: { | ||
+ | def sayHello() { | ||
+ | system.println(" | ||
+ | }; | ||
+ | }; | ||
+ | </ | ||
=== Asynchronous Message Sending === | === Asynchronous Message Sending === |
at/tutorial/actors.txt · Last modified: 2020/02/05 21:26 by elisag