2.3 Actor creation

An actor can send a message only to its acquaintances—other actors whose addresses it knows. Continuation passing is one way in which an actor can learn the addresses of other actors. Another way is for an actor to create other actors as part of its evaluation of a message. Such newly created actors—child actors—can have an independent lifetime from that of the creating actor. Having created new actors, the creating actor can send messages to the new actors, possibly passing its own address as part of those messages.

An actor's ability to create other actors makes it easy to implement fork-join parallelism. For instance, upon receiving a message, an actor may decide to divide up a potentially compute-intensive job and create child actors for the purpose of processing parts of that larger computation. As illustrated in Figure 2.9, a creator actor would divvy up work among its child actors, and wait for the children to complete their work and send their results back to the parent. Once all the results have been collected, the parent actor can summarize those results, possibly sending the results to yet another actor, or continuation. We will provide several examples of fork-join parallelism in later chapters.

image images/childActors90.jpg

Figure 2.9 - Creating and delegating work to child actors.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset