Active Object Design Pattern

  • 7,765 views
Uploaded on

A presentation on the Active Object Design pattern.

A presentation on the Active Object Design pattern.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
7,765
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
108
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Active Object DesignPatternJeremiah Jordan
  • 2. Active Object• Decouples method execution from methodinvocation• Simplifies synchronized access to objects that residein their own threads of control• Commonly used in distributed systems requiringmulti-threaded servers• Often implemented using message passing• Similar to the Actor pattern. In the Actor patterneach Actor is an Active Object.
  • 3. Example Class Diagram• A proxy provides an interface that allowsclients to access methods of an object• A concrete method request is created forevery method invoked on the proxy• A scheduler receives the method requests &dispatches them on the servant when theybecome runnable• An activation list maintains pendingmethod requests• A servant implements the methods• A future allows clients to access the resultsof a method call on the proxyFutureSchedulerinsertdispatchMethodRequestcan_callcall*Proxymethod_1method_nActivationListinsertremoveServantmethod_1method_ncreates creates maintainsConcreteMethodRequest1ConcreteMethodRequest2
  • 4. Sequence Diagram
  • 5. Method Scheduling
  • 6. Method Scheduling(cont)• A client calls a function on a proxy object• The proxy creates a future which will be returnedto the client (If the method returns a result)• The proxy creates a method request which is toldabout the future• The method request is then sent to the schedulerwhich places it in the activation list• If the method is to return a result, the future isreturned to the client
  • 7. Method Dispatch
  • 8. Method Dispatch(cont)• The scheduler checks if the method requestcan be run• If the method request can be run it isremoved from the activation list and called• The method request calls the method on theservant.• If the method has a result, the result iswritten to the associated future
  • 9. Method Dispatch andGuards• Methods have guards which can delay them from beingcalled.• Before the scheduler can have the servant run amethod, it checks if the method can be called• If a method cannot be called, the scheduler goes onto the next method to be run• Example: Queue implemented as an Active Object• Enqueue cannot be called if the queue is full• Dequeue cannot be called if the queue is empty
  • 10. Retrieving Results
  • 11. Retrieving Results(cont)• After the result has been written to thefuture the client can then retrieve it• Reading the result is asynchronous ofcalling the method
  • 12. Example Implementations /References• Actor implementation in Python:http://jodal.github.com/pykka/• Actors for Scala/Java:http://akka.io/• http://www.erlang.org/• “Prefer Using Active Objects Instead of Naked Threads” by Herb Sutterhttp://drdobbs.com/high-performance-computing/225700095• “Pattern-Oriented Software Architecture: Patterns for Concurrent andNetworked Objects” by Douglas C. Schmidt, et al.www1.cse.wustl.edu/~schmidt/POSA/POSA2/www.cs.wustl.edu/~schmidt/posa2.ppt• http://en.wikipedia.org/wiki/Actor_model