My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Links

Actors Guild is an experimental Java framework to make concurrent programming easier. It combines the concept of Actors with Futures. The result is a small API that let's you write concurrent, multi-threaded code almost like regular Java classes.

Example of a simple actor:

abstract class Counter extends Actor
{
    private int count;

    @Prop abstract int getInitialCount();

    @Initializer
    public void init() {
        count = getInitialCount();
    }

    @Message
    public AsyncResult<Integer> getCount() {
        return result(count);
    }

    @Message
    public AsyncResult<Void> add(int a) {
        count = count + a;
        return noResult();
    }   
}

Creating the actor and using its messages:

Agent agent = new DefaultAgent(); // the Agent manages Actors
Counter counter = agent.create(Counter.class, new Props("initialCount", 1));
counter.add(5).await();           // call add(), wait until message has been processed
System.out.println("Result: "+counter.getCount().get());  // will print 6

More information on Actorsguildframework.org.

Powered by Google Project Hosting