mandala.rami.impl
Class ListAsynchronousPolicy

java.lang.Object
  extended bymandala.rami.impl.ListAsynchronousPolicy
All Implemented Interfaces:
AsynchronousPolicy, java.io.Serializable, SingleThreadedSemantic
Direct Known Subclasses:
FifoPolicy, RandomPolicy

public abstract class ListAsynchronousPolicy
extends java.lang.Object
implements AsynchronousPolicy, SingleThreadedSemantic, java.io.Serializable

Abstract implementation of the SingleThreadedSemantic backed by a List which stores asynchronous methods invocation request.

A List is used to store method invocation requests. A thread sleeps continuously waiting for some requests. When such a request is made, it is inserted in the methods list and the invoker thread is awaken. This thread removes the request from the methods list, runs the request using an instance of the MethodInvoker class and returns to sleep if no more requests are in the methods list.

The selection of the next request to be served by the invoker thread must be customized by subclasses in the select() method.

Version:
1.0
Author:
eipi
See Also:
SingleThreadedSemantic, AsynchronousPolicy, MethodInvoker, List, Serialized Form

Field Summary
protected static int DELTA_PRIORITY
          The invoker thread is given priority equals to NORM_PRIORITY + DELTA_PRIORITY.
protected  mandala.rami.impl.ListAsynchronousPolicy.InvokerThread invokerThread
          The invoker thread instance used to invoke methods.
protected  java.util.List methods
          The list of methods to be invoked by the invokerThread.
protected static int threadPriority
          Priority of the invoker thread.
 
Constructor Summary
ListAsynchronousPolicy(java.lang.String name, java.util.List list)
          Creates a new ListAsynchronousPolicy instance.
 
Method Summary
 Cancelable call(java.lang.Object object, FutureServer futureServer)
          Asynchronous implementation of a method invocation.
protected  void finalize()
           
 int getCurrentSize()
          Gets the current size methods.
 java.lang.Thread getInvokerThread()
          Gets the thread which is responsible of methods invocation.
protected abstract  MethodInvoker select()
          Returns the next MethodInvoker object to be runned into the invoker thread<.p>
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

methods

protected transient java.util.List methods

The list of methods to be invoked by the invokerThread.

See Also:
getCurrentSize(), invokerThread

DELTA_PRIORITY

protected static final int DELTA_PRIORITY

The invoker thread is given priority equals to NORM_PRIORITY + DELTA_PRIORITY.

See Also:
ThreadOp, Constant Field Values

threadPriority

protected static final int threadPriority

Priority of the invoker thread.

See Also:
ThreadOp, Constant Field Values

invokerThread

protected transient mandala.rami.impl.ListAsynchronousPolicy.InvokerThread invokerThread

The invoker thread instance used to invoke methods.

Constructor Detail

ListAsynchronousPolicy

public ListAsynchronousPolicy(java.lang.String name,
                              java.util.List list)

Creates a new ListAsynchronousPolicy instance.

Parameters:
name - the name of the invoker thread
list - the implementation of the List interface to use
See Also:
invokerThread, getInvokerThread()
Method Detail

select

protected abstract MethodInvoker select()

Returns the next MethodInvoker object to be runned into the invoker thread<.p>

Returns:
the next MethodInvoker to be runned into the invoker thread
See Also:
invokerThread, getInvokerThread()

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable

call

public final Cancelable call(java.lang.Object object,
                             FutureServer futureServer)

Asynchronous implementation of a method invocation.

This implementation enqueue the method into the methods list. The method will be dequeued by the invokerThread through the invocation of select().

Specified by:
call in interface AsynchronousPolicy
Parameters:
object - the object on which the method is to be invoked.
futureServer - a FutureServer value
Returns:
the cancelable object to use to cancel the invocation.
See Also:
MethodInvoker, FutureServer, methods, invokerThread, select()

getInvokerThread

public java.lang.Thread getInvokerThread()

Gets the thread which is responsible of methods invocation.

Returns:
a ThreadOp value

getCurrentSize

public int getCurrentSize()

Gets the current size methods.

Warning: the information gathered with this method is by nature ephemeral: when this method returns, the current size may already have changed.

Returns:
the size of the {link #methods} list

toString

public java.lang.String toString()


Mandala help mailing list