org.actorsguildframework.annotations
Enum ConcurrencyModel

java.lang.Object
  extended by java.lang.Enum<ConcurrencyModel>
      extended by org.actorsguildframework.annotations.ConcurrencyModel
All Implemented Interfaces:
Serializable, Comparable<ConcurrencyModel>

public enum ConcurrencyModel
extends Enum<ConcurrencyModel>

ConcurrencyModel describes the way concurrency is handled in the actor and its methods.


Enum Constant Summary
MultiThreaded
          Specifies a multi-threaded model: several simultaneous thread can run in the actor.
SingleThreaded
          Specifies a single-threaded model: only one simultaneous thread in the actor is allowed.
Stateless
          Specifies a stateless model: several simultaneous thread can run in the actor, but they can not share any state in the actor.
 
Method Summary
 boolean isMultiThreadingCapable()
          Returns true if this model is multi-threaded, and thus either MultiThreaded or Stateless.
static ConcurrencyModel valueOf(String name)
          Returns the enum constant of this type with the specified name.
static ConcurrencyModel[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

SingleThreaded

public static final ConcurrencyModel SingleThreaded
Specifies a single-threaded model: only one simultaneous thread in the actor is allowed.

All messages will be processed in the order that they have been queued.


MultiThreaded

public static final ConcurrencyModel MultiThreaded
Specifies a multi-threaded model: several simultaneous thread can run in the actor.

The order of execution for multi-threaded messages is not defined. Thus they may be executed in a different order than the order to queuing.

Please note that Stateless should be preferred to MultiThreaded where possible, because it is much safer.


Stateless

public static final ConcurrencyModel Stateless
Specifies a stateless model: several simultaneous thread can run in the actor, but they can not share any state in the actor. At runtime Stateless works exactly like MultiThreaded. However, at the first instantiation actors declared as Stateless run through a number of checks to validate that the actor does not maintain any state other than configuration data set at creation.

In order to ensure this, there are strict rules for Stateless actors. In an actor that is declared as Stateless (using a Model annotation for the class), there are the following restrictions for the fields used in the actor and any super-classes:

The order of execution for stateless messages is not defined. Thus they may be executed in a different order than the order to queuing.

Method Detail

values

public static final ConcurrencyModel[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(ConcurrencyModel c : ConcurrencyModel.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static ConcurrencyModel valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name

isMultiThreadingCapable

public boolean isMultiThreadingCapable()
Returns true if this model is multi-threaded, and thus either MultiThreaded or Stateless.

Returns:
true for multi-threaded models, false otherwise