The Meta-Environment API

toolbus.adapter
Class ToolBridge.ThreadLocalJobQueue

java.lang.Object
  extended by toolbus.adapter.ToolBridge.ThreadLocalJobQueue
Enclosing class:
ToolBridge

private class ToolBridge.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<ToolBridge.Job> requests
           
 
Constructor Summary
ToolBridge.ThreadLocalJobQueue()
          Default constructor.
 
Method Summary
 void acknowledge()
          Acknowledges the last job that was send from the source the current thread is associated with.
 ToolBridge.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.
 ToolBridge.Job postRequest(aterm.ATerm aTerm, long threadId)
          Schedules the given request for transmission to the ToolBus.
 aterm.ATermAppl waitForResponse(ToolBridge.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<ToolBridge.Job> requests

awaitingAck

private boolean awaitingAck
Constructor Detail

ToolBridge.ThreadLocalJobQueue

public ToolBridge.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 ToolBridge.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.ATermAppl waitForResponse(ToolBridge.Job job)

getNext

public ToolBridge.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