Re: [OpenMap Users] Layer dosen't "update" after call to MapBean.setCenter(lat, lon) (UNCLASSIFIED)

From: David Ward <synriga_at_yahoo.com>
Date: Thu, 31 Jan 2008 16:56:51 -0800 (PST)

>Is everyone seeing this behavior with the current, OpenMap 4.6.3 release? I have not seen this behavior in 4.6.3. In our application we have several regions of code that perform scale and center operations. We have more than 20 layers (almost all OMGraphicHandlerLayers) and have not witnessed this situation. Several of the layers are pumped with data from separate data acquisition threads. In the early days (almost 5 years ago) of development of our application I vaguely recall having issues where the graphics would not render in the proper location (or not at all) but I believe (if I remember correctly) those problems were caused by manipulating the graphic handler's graphic list outside if the prepare method. Our application is routinely executed on Dual and Quad processor machines. We use Java 6.0. Cheers, David ----- Original Message ---- From: Don Dietrick <dietrick_at_bbn.com> To: "Lackey, Michael B. (SED/BTI)" <michael.lackey1_at_us.army.mil> Cc: Carsten Ø. Madsen <com_at_navicon.dk>; Davidian <kroberts_at_syrres.com>; openmap-users_at_bbn.com Sent: Thursday, January 31, 2008 3:40:59 PM Subject: Re: [OpenMap Users] Layer dosen't "update" after call to MapBean.setCenter(lat, lon) (UNCLASSIFIED) Hi Michael, This code has been changed for the next OpenMap release. The beta on the website has more thread protection on the SwingWorker. Is everyone seeing this behavior with the current, OpenMap 4.6.3 release? Is anyone seeing it with the 4.6.4 beta? I can't reproduce these problems with my current code base, but I haven't tried firing up 4.6.3 yet. Regards, - Don Lackey, Michael B. (SED/BTI) wrote: > Classification: UNCLASSIFIED > Caveats: NONE > > Carsten, > > While we're on the subject of threading, I'm wondering if anybody else can see this, or if I've got it totally wrong. There is a question I've had for some time now, lsince we started customizing the LocatioLayer. The question is: > > Why is doPrepare() not a synchronized method? > > When I examine LocationLayer, I see the following in doPrepare(): > > public void doPrepare() { > // If there isn't a worker thread working on a projection > // changed or other doPrepare call, then create a thread that > // will do the real work. If there is a thread working on > // this, then set the cancelled flag in the layer. > if (currentWorker == null) { > currentWorker = new LocationWorker(); > currentWorker.execute(); > } else > setCancelled(true); > > What if you are running in a multi-threaded environment, and the following happens: > > (1) doPrepare() tests currentWorker and finds it non-null > > (2) doPrepare() jumps to the setCancelled(true) call, but at that instant in time is suspended, before it can make the call. In effect the thread is suspended between the "else" statement and the "setCancelled(true)" statement. Like this: > > public void doPrepare() { > // If there isn't a worker thread working on a projection > // changed or other doPrepare call, then create a thread that > // will do the real work. If there is a thread working on > // this, then set the cancelled flag in the layer. > if (currentWorker == null) { > currentWorker = new LocationWorker(); > currentWorker.execute(); > } else > <<<------thread was suspended at this instant in time, at this location > setCancelled(true); > > 3. Now, for fun, let's say the worker thread is resumed and completes it's work. The thread calls workerComplete(), tests (isCancelled==false), determines result to be true, and starts (perhaps completes) the repaint. > > 4. At some later time, the orignial thread resumes executon and makes the call "setCancelled(true)". Now the cancelled flag is true, when it really should not be. > > Can you follow my logic? If so, do you think this might be a problem iff (note spelling) the sequence of events described above happens? > > Mike Lackey > > -----Original Message----- > From: owner-openmap-users_at_bbn.com [mailto:owner-openmap-users_at_bbn.com] On Behalf Of "Carsten Ø. Madsen" > Sent: Thursday, January 31, 2008 8:04 AM > To: Davidian > Cc: openmap-users_at_bbn.com > Subject: Re: [OpenMap Users] Layer dosen't "update" after call to MapBean.setCenter(lat, lon) > > Sounds like a threading problem then. Each of the projection change events triggers doPrepare that launches a new thread that calls prepare so it is very likely that your prepare method etc could be run simultaneously (e.g., multi core box). Try putting in a small sleep between setCenter & setScale to verify this. If that works fix the threading problem in your layer. > BR > Carsten > > Davidian wrote: > >> Carsten, >> >> Yes, I've confirmed that the layer is getting a ProjectionChanged >> event every time I call setCenter. As a matter of fact, it looks like >> it is getting two such events. I'm sure that is because I am calling >> setCenter() on the MapBean, and then following that with setScale(). >> >> Also, I am extending OMGraphicHandlerLayer. I checked the code in >> that class, and generate() is getting called for sure in the prepare() method. >> >> Thanks for your help so far. >> >> -Kennedy >> >> >> >> oland wrote: >> >> >>> Hi >>> >>> Does the layer receive a projection change event after the call to >>> setCenter? >>> >>> Override prepare and check that generate is called on the list >>> returned by getList() and that the list is not empty when this is done. >>> >>> BR >>> Carsten >>> >>> >>> >>> >> >> > > -- > [To unsubscribe to this list send an email to "majdart_at_bbn.com" > with the following text in the BODY of the message "unsubscribe openmap-users"] > Classification: UNCLASSIFIED > Caveats: NONE > > -- > [To unsubscribe to this list send an email to "majdart_at_bbn.com" > with the following text in the BODY of the message "unsubscribe openmap-users"] > -- [To unsubscribe to this list send an email to "majdart_at_bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Jan 31 2008 - 20:24:25 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT