The Meta-Environment API

toolbus
Class AbstractTool.ThreadLocalJobQueue

java.lang.Object
  extended by toolbus.AbstractTool.ThreadLocalJobQueue
Enclosing class:
AbstractTool

private class AbstractTool.ThreadLocalJobQueue
extends java.lang.Object

This job queue holds all the jobs that are posted by a certain thread.

Author:
Arnold Lankamp

Field Summary
private  boolean awaitingAck
           
private  java.util.List<AbstractTool.Job> requests
           
 
Constructor Summary
AbstractTool.ThreadLocalJobQueue()
          Default constructor.
 
Method Summary
 void acknowledge()
          Acknowledges the last job that was send from the source the current thread is associated with.
 AbstractTool.Job getNext()
          Returns the next job in the queue.
 void postEvent(aterm.ATerm aTerm, long threadId)
          Schedules the given event for transmission to the ToolBus.
 AbstractTool.Job postRequest(aterm.ATerm aTerm, long threadId)
          Schedules the given request for transmission to the ToolBus.
 aterm.ATerm waitForResponse(AbstractTool.Job job)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requests

private final java.util.List<AbstractTool.Job> requests

awaitingAck

private boolean awaitingAck
Constructor Detail

AbstractTool.ThreadLocalJobQueue

public AbstractTool.ThreadLocalJobQueue()
Default constructor.

Method Detail

postEvent

public void postEvent(aterm.ATerm aTerm,
                      long threadId)
Schedules the given event for transmission to the ToolBus. If there are currently no jobs in the thread local queue, the event will be send immediately; otherwise we'll need to wait till all the jobs (associated with the current thread) that were previously scheduled have been submitted to the request queue.

Parameters:
aTerm - The term that hold the details about the event.
threadId - The id of the thread associated with the event.

postRequest

public AbstractTool.Job postRequest(aterm.ATerm aTerm,
                                    long threadId)
Schedules the given request for transmission to the ToolBus. If there are currently no jobs in the thread local queue, the event will be send immediately; otherwise we'll need to wait till all the jobs (associated with the current thread) that were previously scheduled have been submitted to the request queue.

Parameters:
aTerm - The term that hold the details about the request.
threadId - The id of the thread associated with the request.
Returns:
The received response on the issued request.

waitForResponse

public aterm.ATerm waitForResponse(AbstractTool.Job job)

getNext

public AbstractTool.Job getNext()
Returns the next job in the queue.

Returns:
The next job in the queue; null if the queue is empty.

acknowledge

public void acknowledge()
Acknowledges the last job that was send from the source the current thread is associated with. It will submit the next job in the queue if there are any.


The Meta-Environment API