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]

Re: frysk-core frysk/proc/Proc.java frysk/proc/Cha ...


Mark,
FYI, this is going to get radical make-over anyway, I'd not be in much of a hurry to nitpick the current code. The only immediate concerns are the interface and the unit tests.
Andrew


Mark Wielaard wrote:
Hi Nurdin,

On Fri, 2006-10-13 at 14:59 +0000, npremji@sourceware.org wrote:
	frysk-core/frysk/proc/CL
	* Proc.java (requestRemoveAllObservations): Added. Tool to easily remove
	all observations from a process, causing a detach.

--- frysk-core/frysk/proc/Proc.java 2006/10/12 22:05:43 1.84
+++ frysk-core/frysk/proc/Proc.java 2006/10/13 14:59:24 1.85
@@ -235,6 +235,40 @@
}
/**
+ * Request that the Proc remove all of its observations.
+ * Should cause a detach.
+ */
+ public synchronized void requestRemoveAllObservations()
+ {
+ Iterator iter = observationsIterator();
+ while (iter.hasNext())
+ {
+ Observation observation = (Observation) iter.next(); + Manager.eventLoop.add (new Observation (observation.observable, + observation.observer)
+ {
+ public void execute ()
+ {
+ newState = oldState ().handleDeleteObservation
+ (Proc.this, this);
+ }
+
+ public void handleAdd ()
+ {
+ // TODO Auto-generated method stub
+ + }
+
+ public void handleDelete ()
+ {
+ // TODO Auto-generated method stub
+ + }
+ });



You unwrap the Observation, take out the observable and observer and then add dummy handleAdd() and handleDelete() methods. This seems not safe. The Observation could have a specialized handleDelete() method (to attach it to a specific Task for example). You should probably use an Event and in the execute() do the handleDeleteObservation() on the original observation.

- public boolean addObservation(Object o)
+ public synchronized boolean addObservation(Object o)
{
return observations.add(o);
}
- public boolean removeObservation (Object o)
+ public synchronized boolean removeObservation (Object o)
{
return observations.remove(o);
}

It took me a while to realize why these synchronized statements are now necessary. Some documentation about the interaction between the iterator and the add and remove methods would be good.

Cheers,

Mark



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