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

From: Lackey, Michael B. (SED/BTI) <"Lackey,>
Date: Fri, 1 Feb 2008 08:14:34 -0600

Classification: UNCLASSIFIED
Caveats: NONE

Hello Don,

Other than the "multiple projection change events", I've never seen or trapped the case I described. It was a theoritical something I saw noticed we started customizing the layer, but experience shows that under the right conditions even a very small window can be found. But only occasionaly, which makes them so maddening.

I was able to resolve the "multiple projection change events" by changing order and/or adding sleep(). I think I will extend MapBean and add a SetCenterScale() that only fires one event, that seems like the simplest solution to me, but I'm also open to any/all suggestions.

Mike Lackey

-----Original Message-----
From: Don Dietrick [mailto:dietrick_at_bbn.com]
Sent: Thursday, January 31, 2008 5:41 PM
To: Lackey, Michael B. (SED/BTI)
Cc: "Carsten . Madsen"; Davidian; openmap-users_at_bbn.com
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"]
>

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"]
Received on Fri Feb 01 2008 - 09:16:24 EST

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