This is the mail archive of the frysk@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

draft patch to add signaled observers to the ui


I've added task signaled observer to the UI. When the relevant observer event happens, two default actions take place. A log action, and a plot to the eventviewer widget of that task, if it has a widget.

Regards

Phil
Index: frysk/gui/monitor/ChangeLog
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/monitor/ChangeLog,v
retrieving revision 1.389
diff -r1.389 ChangeLog
2a3,7
> 	* observers/TaskSignaledObserver.java (TaskSignaledObserver): New.
> 	* observers/ObserverManager.java (initTaskObservers): Instantiate Signaled 
> 	observer.
> 	* StatusWidget.java (addObserverActionPoint): Add signaled observer.
> 	(TimelineAction.createEvent): Ditto.
Index: frysk/gui/monitor/StatusWidget.java
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/monitor/StatusWidget.java,v
retrieving revision 1.64
diff -r1.64 StatusWidget.java
64a65
> import frysk.gui.monitor.observers.TaskSignaledObserver;
167a169,173
> 		
> 		if (observer instanceof TaskSignaledObserver) {
> 			((TaskSignaledObserver)observer).taskActionPoint.addAction(new TimelineAction(
> 					observer, guiData));
> 		}
282a289,293
>       else if (observer.getBaseName().equals("Signaled Observer"))
>         {
>           observerglyph = 1;
>           observercolor = 1;
>         }
Index: frysk/gui/monitor/observers/ObserverManager.java
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/monitor/observers/ObserverManager.java,v
retrieving revision 1.41
diff -r1.41 ObserverManager.java
112a113,119
> 		
> 		//============================================
> 		ObserverRoot observer = new TaskSignaledObserver();
> 		observer.dontSaveObject();
> 		this.tryAddTaskObserverPrototype(observer);
> 		this.addBaseObserverPrototype((ObserverRoot) observer.getCopy());
> 		
114c121
< 		ObserverRoot observer = new TaskExecObserver();
---
> 		observer = new TaskExecObserver();
Index: frysk/gui/monitor/observers/TaskSignaledObserver.java
===================================================================
RCS file: frysk/gui/monitor/observers/TaskSignaledObserver.java
diff -N frysk/gui/monitor/observers/TaskSignaledObserver.java
0a1,154
> // This file is part of the program FRYSK.
> //
> // Copyright 2006, Red Hat Inc.
> //
> // FRYSK is free software; you can redistribute it and/or modify it
> // under the terms of the GNU General Public License as published by
> // the Free Software Foundation; version 2 of the License.
> //
> // FRYSK is distributed in the hope that it will be useful, but
> // WITHOUT ANY WARRANTY; without even the implied warranty of
> // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> // General Public License for more details.
> // type filter text
> // You should have received a copy of the GNU General Public License
> // along with FRYSK; if not, write to the Free Software Foundation,
> // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
> // 
> // In addition, as a special exception, Red Hat, Inc. gives You the
> // additional right to link the code of FRYSK with code not covered
> // under the GNU General Public License ("Non-GPL Code") and to
> // distribute linked combinations including the two, subject to the
> // limitations in this paragraph. Non-GPL Code permitted under this
> // exception must only link to the code of FRYSK through those well
> // defined interfaces identified in the file named EXCEPTION found in
> // the source code files (the "Approved Interfaces"). The files of
> // Non-GPL Code may instantiate templates or use macros or inline
> // functions from the Approved Interfaces without causing the
> // resulting work to be covered by the GNU General Public
> // License. Only Red Hat, Inc. may make changes or additions to the
> // list of Approved Interfaces. You must obey the GNU General Public
> // License in all respects for all of the FRYSK code and other code
> // used in conjunction with FRYSK except the Non-GPL Code covered by
> // this exception. If you modify this file, you may extend this
> // exception to your version of the file, but you are not obligated to
> // do so. If you do not wish to provide this exception without
> // modification, you must delete this exception statement from your
> // version and license this file solely under the GPL without
> // exception.
> package frysk.gui.monitor.observers;
> 
> import frysk.gui.monitor.GuiObject;
> import frysk.gui.monitor.actions.TaskActionPoint;
> import frysk.gui.monitor.filters.TaskFilterPoint;
> import frysk.proc.Action;
> import frysk.proc.Manager;
> import frysk.proc.Task;
> import frysk.proc.TaskObserver;
> 
> /**
>  * @author pmuldoon
>  *
>  */
> public class TaskSignaledObserver extends TaskObserverRoot implements
> 		TaskObserver.Signaled {
> 
> 	public TaskFilterPoint taskFilterPoint;
> 
> 	public TaskActionPoint taskActionPoint;
> 
> 	/**
> 	 * TaskSignalObserver. Extends TaskObserverRoot and implements TaskObserver.Signaled
> 	 * 
> 	 * Provides functionality for the Signaled Frysk Core observer in the UI.
> 	 */
> 	public TaskSignaledObserver() {
> 		super("Signaled Observer",
> 				"Fires every time this tasks has a pending signal l");
> 
> 		taskFilterPoint = new TaskFilterPoint("Pending Signal Thread",
> 				"The thread that has the pending signal");
> 		addFilterPoint(taskFilterPoint);
> 
> 		taskActionPoint = new TaskActionPoint(taskFilterPoint.getName(),
> 				taskFilterPoint.getToolTip());
> 		addActionPoint(taskActionPoint);
> 
> 	}
> 
> 	/**
> 	 * TaskSignalObserver. Extends TaskObserverRoot and implements TaskObserver.Signaled
> 	 * 
> 	 * Provides functionality for the Signaled Frysk Core observer in the UI. Produces a
> 	 * new TaskSignalOberser from the observer passed as a parameter. This is used in cloning
> 	 * the observer.
> 	 */
> 	public TaskSignaledObserver(final TaskSignaledObserver other) {
> 		super(other);
> 
> 		taskFilterPoint = new TaskFilterPoint(other.taskFilterPoint);
> 		addFilterPoint(taskFilterPoint);
> 
> 		taskActionPoint = new TaskActionPoint(other.taskActionPoint);
> 		addActionPoint(taskActionPoint);
> 	}
> 
> 	/* (non-Javadoc)
> 	 * @see frysk.gui.monitor.observers.TaskObserverRoot#apply(frysk.proc.Task)
> 	 */
> 	public void apply(final Task task) {
> 		task.requestAddSignaledObserver(this);
> 	}
> 
> 	/* (non-Javadoc)
> 	 * @see frysk.gui.monitor.observers.TaskObserverRoot#unapply(frysk.proc.Task)
> 	 */
> 	public void unapply(final Task task) {
> 		task.requestDeleteSignaledObserver(this);
> 	}
> 
> 	/* (non-Javadoc)
> 	 * @see frysk.proc.TaskObserver$Signaled#updateSignaled(frysk.proc.Task, int)\]
> 	 * 
> 	 */
> 	public Action updateSignaled(final Task task, final int signal) {
> 		org.gnu.glib.CustomEvents.addEvent(new Runnable() {
> 			public void run() {
> 				bottomHalf(task, signal);
> 			}
> 		});
> 		return Action.BLOCK;
> 	}
> 
> 	private void bottomHalf(final Task task, final int signal) {
> 		setInfo(getName() + ": " + "PID: " + task.getProc().getPid()
> 				+ " TID: " + task.getTid() + " Event: has pending signal: "
> 				+ signal + " Host: " + Manager.host.getName());
> 		if (runFilters(task)) {
> 			this.runActions(task);
> 		}
> 
> 		final Action action = whatActionShouldBeReturned();
> 		if (action == Action.CONTINUE) {
> 			task.requestUnblock(this);
> 		}
> 	}
> 
> 	private void runActions(final Task task) {
> 		super.runActions();
> 		taskActionPoint.runActions(task);
> 	}
> 
> 	private boolean runFilters(final Task task) {
> 		return filter(task);
> 	}
> 
> 	public GuiObject getCopy() {
> 		return new TaskSignaledObserver(this);
> 	}
> 
> 	private boolean filter(final Task task) {
> 		return taskFilterPoint.filter(task);
> 	}
> 
> }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]