llnl.visit
Class EventLoop

java.lang.Object
  extended by llnl.visit.EventLoop
All Implemented Interfaces:
SimpleObserver

public class EventLoop
extends java.lang.Object
implements SimpleObserver


Constructor Summary
EventLoop(EventLoop obj)
          Copy constructor that we can use to initialize a new object.
EventLoop(llnl.visit.Xfer x, MessageAttributes m, SyncAttributes s)
          Constructor for the EventLoop class.
 
Method Summary
 void Execute()
          Execute the event loop, reading input from the viewer as it comes in.
 boolean GetUpdate()
          Returns that flag indicating whether or not Update() should be called in response to a state object's Notify().
 boolean Process()
          Expose Process method so we can call it periodically from event-driven programs without having to do another thread.
 void SetUpdate(boolean val)
          Sets a flag in the implementing class that determines whether or not the Update() method should be called in response to the state object's Notify() method being called.
 void StartProcessing()
          Start processing input from the viewer on a 2nd thread so it automatically comes in and we don't have to explicitly do it ourselves.
 void StopProcessing()
          Stop processing input from the viewer on a 2nd thread.
 boolean Synchronize()
          Send a synchronize message to the viewer and wait for it to come back.
 void Update(AttributeSubject subj)
          This method is called when syncAttributes or messageAttributes update from the viewer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventLoop

public EventLoop(llnl.visit.Xfer x,
                 MessageAttributes m,
                 SyncAttributes s)
Constructor for the EventLoop class.

Parameters:
x - The xfer object that will be used to talk to the viewer.
m - The message attributes object we'll use to detect error messages.
s - The sync attributes

EventLoop

public EventLoop(EventLoop obj)
Copy constructor that we can use to initialize a new object.

Parameters:
obj - The event loop that will be used to initialize the new one.
Method Detail

Execute

public void Execute()
Execute the event loop, reading input from the viewer as it comes in.


Process

public boolean Process()
                throws LostConnectionException
Expose Process method so we can call it periodically from event-driven programs without having to do another thread. This method does nothing if we've started processing input on another thread.

Returns:
True if there was input to read; otherwise false.
Throws:
LostConnectionException

Synchronize

public boolean Synchronize()
Send a synchronize message to the viewer and wait for it to come back. If running a multithreaded event loop, this method should only be called on thread 1 and never on the read thread, thread 2.

Returns:
True if the synchronize had no error; False if there was an error.

StartProcessing

public void StartProcessing()
Start processing input from the viewer on a 2nd thread so it automatically comes in and we don't have to explicitly do it ourselves.


StopProcessing

public void StopProcessing()
Stop processing input from the viewer on a 2nd thread.


Update

public void Update(AttributeSubject subj)
This method is called when syncAttributes or messageAttributes update from the viewer.

Specified by:
Update in interface SimpleObserver
Parameters:
subj - The subject that caused the update.

SetUpdate

public void SetUpdate(boolean val)
Description copied from interface: SimpleObserver
Sets a flag in the implementing class that determines whether or not the Update() method should be called in response to the state object's Notify() method being called.

Specified by:
SetUpdate in interface SimpleObserver
Parameters:
val - true if the Update() method should be called in response to a Notify().

GetUpdate

public boolean GetUpdate()
Description copied from interface: SimpleObserver
Returns that flag indicating whether or not Update() should be called in response to a state object's Notify().

Specified by:
GetUpdate in interface SimpleObserver
Returns:
The flag indicating whether Update() should be called.