World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 05-16-2012, 04:22 AM   #1
jas511
Senior Member
 
Join Date: Aug 2009
Posts: 244
jas511 is on a distinguished road
Default ConcurrentLinkedQueue in RenderableLayer

Is there a particular reason that RenderableLayer users a ConcurrentLinkedQueue? Is there actually thread safety needed there?

I ask because it would be nice to use a list so we could add renderables to either the beginning or the end of the list.
__________________
Jeff Storey
Software Developer
http://jeffastorey.blogspot.com
jas511 is offline   Reply With Quote
Old 05-24-2012, 06:15 PM   #2
tag
WWJ Technical Manager
 
Join Date: May 2007
Location: Seattle
Posts: 1,027
tag is on a distinguished road
Default

While it's not recommended, some apps add and remove renderables on threads other than the EDT. Use of ConcurrentLinkedQueue is intended to reduce the likelihood of problems caused by that. To simulate list behavior, I suggest you subclass RenderableLayer and add a method that provides list-like behavior.
tag is offline   Reply With Quote
Old 05-29-2012, 02:58 PM   #3
jas511
Senior Member
 
Join Date: Aug 2009
Posts: 244
jas511 is on a distinguished road
Default

Thanks. I think at this point getting the list behavior would be more difficult than its worth. Since renderables is internal to RenderableLayer, we really can't change the behavior. We could add a different variable to our subclass but there is no guarantee that RenderableLayer wouldn't still try to use its internal renderables variable (especially as implementations of worldwind change). The safest bet would probably be to create a subclass of AbstractLayer that is similar to RenderableLayer - though I don't like this idea because it would have a lot of duplication.

There is always the options to modify the source to use a list since we're not trying to access them off the EDT, and now that I know that's the reason, it wouldn't be too hard to change that and add list behavior.
__________________
Jeff Storey
Software Developer
http://jeffastorey.blogspot.com
jas511 is offline   Reply With Quote
Old 05-29-2012, 05:34 PM   #4
tag
WWJ Technical Manager
 
Join Date: May 2007
Location: Seattle
Posts: 1,027
tag is on a distinguished road
Default

What I meant was that you could subclass a layer that implements indexed insert and remove methods by manipulating the current queue. insert would create a new queue that's a copy of the old one with the new Renderable(s) inserted. Likewise for remove. This could work okay if the frequency of calls to insert and remove was relatively low. This would essentially implement the behavior of CopyOnWriteArrayList.

Alternatively, I've just declared the current queue to be protected (it was private) so you could set the list to be whatever you want in a subclass' constructor, and add your indexed insert and remove operations to that subclass. It's declaration, Collection<Renderable>, does not require a thread-safe collection. I haven't tried this, but I don't see off-hand any problems with it.
tag is offline   Reply With Quote
Old 05-29-2012, 05:51 PM   #5
jas511
Senior Member
 
Join Date: Aug 2009
Posts: 244
jas511 is on a distinguished road
Default

Thanks. Currently we are doing something similar to the first approach to simulate list behavior, but if you've noted, performance can be tricky. With your new changes, we should be able to use a list instead. Thanks for the quick reply.
__________________
Jeff Storey
Software Developer
http://jeffastorey.blogspot.com
jas511 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Bug] WorldWindowGLAutoDrawable reinitialize clears RenderableLayer mike.emery Feature Discussion 6 04-20-2011 04:39 PM
RenderableLayer removes all SurfacePolygons on resize benlawry Development Help 2 12-08-2010 05:17 PM
RenderableLayer - use a Set instead of ArrayList? Joao Fonseca Feature Discussion 0 03-28-2008 09:25 PM
ConcurrentModificationException in RenderableLayer jjones Development Help 1 02-21-2008 12:45 PM
Refactor RenderableLayer? zerobarrier Development Help 3 01-16-2008 07:09 AM


All times are GMT +1. The time now is 02:08 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.