/*
 * Created on Jan 4, 2005
 */
package javax.realtime.test.bridge;

import javax.realtime.AsyncEventHandler;
import javax.realtime.RealtimeThread;

import javax.realtime.DSS.DSS;

/**
 * A simple <A HREF="AsyncEventHandler"><CODE>AsyncEventHandler</CODE></A> used
 * to handle <CODE>Bridge observer created</CODE> happenings.
 * @author gary
 */

/*
 * TO DO: fix fire count handling
 */
public class BridgeObserver extends AsyncEventHandler {
	
	/**
	 * Constructor
	 * @param thread the <A HREF="RealTimeThread.html">
	 * <CODE>RealTimeThread</CODE></A>
	 * associated with this <A HREF="AsyncEventHandler.html">
	 * <CODE>AsyncEventHandler</CODE></A>.
	 */
	public BridgeObserver( RealtimeThread thread ) {
		// System.out.println( "BridgeObserver(" + thread + ")" );
		this.thread = thread;
	}
	
	/**
	 * If this handler was constructed using a separate Runnable object, then
	 * that Runnable object's run method is called.  This method will be
	 * invoked repeatedly while fireCount is greater than zero.
	 */
	public void handleAsyncEvent() {
		// System.out.println( "BridgeObserver.handleAsyncEvent()" );
		getAndClearPendingFireCount();
		DSS.activate( thread );
	}
	
	/**
	 * The <A HREF="RealTimeThread.html"><CODE>RealTimeThread</CODE></A> associated
	 * with this  <A HREF="AsyncEventHandler.html">
	 * <CODE>AsyncEventHandler</CODE></A>.
	 */
	private RealtimeThread thread;
}

