On 2010/03/23 13:18:39, Paul Lindner wrote: > A different way of dealing with > https://issues.apache.org/jira/browse/SHINDIG-1283 ...
14 years, 1 month ago
(2010-03-23 15:14:53 UTC)
#2
On 2010/03/23 13:18:39, Paul Lindner wrote:
> A different way of dealing with
> https://issues.apache.org/jira/browse/SHINDIG-1283
The Jira indicates the usage of ConcurrentHashMap which supposedly not required
to use synchronize. Wouldn't that be a better way then using synchronized and
copy the map for every change?
The map is constructed at startup and then never modified, so this is a decent ...
14 years, 1 month ago
(2010-03-23 16:02:13 UTC)
#3
The map is constructed at startup and then never modified, so this is a
decent solution, akin to a CopyOnWrite datastructure.
On Tue, Mar 23, 2010 at 8:14 AM, <zhoresh@gmail.com> wrote:
> On 2010/03/23 13:18:39, Paul Lindner wrote:
>
>> A different way of dealing with
>> https://issues.apache.org/jira/browse/SHINDIG-1283
>>
>
> The Jira indicates the usage of ConcurrentHashMap which supposedly not
> required to use synchronize. Wouldn't that be a better way then using
> synchronized and copy the map for every change?
>
>
>
> http://codereview.appspot.com/669043/show
>
http://codereview.appspot.com/669043/diff/1/2 File java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java (right): http://codereview.appspot.com/669043/diff/1/2#newcode73 java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java:73: private ImmutableMap<String, FeatureNode> featureMap; I think this needs to ...
14 years, 1 month ago
(2010-03-23 18:58:09 UTC)
#4
http://codereview.appspot.com/669043/diff/1/2
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java
(right):
http://codereview.appspot.com/669043/diff/1/2#newcode73
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java:73:
private ImmutableMap<String, FeatureNode> featureMap;
I think this needs to be tagged as volatile to make sure all threads get the
latest version.
http://codereview.appspot.com/669043/diff/1/2#newcode455
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java:455:
protected synchronized void loadFeature(Uri parent, String xml) throws
GadgetException {
We may not need to synchronized this with volatile since the map is made
immutable.
On 2010/03/23 16:02:13, Paul Lindner wrote: > The map is constructed at startup and then ...
14 years, 1 month ago
(2010-03-23 20:35:15 UTC)
#5
On 2010/03/23 16:02:13, Paul Lindner wrote:
> The map is constructed at startup and then never modified, so this is a
> decent solution, akin to a CopyOnWrite datastructure.
In that case then it doesn't matter that much true.
But I am not sure what is the penalty in using ConcurentHashMap.
In any case I wouldn't want to use volatile as Henry suggested, since we don't
really want to serialize any read requests.
>
> On Tue, Mar 23, 2010 at 8:14 AM, <mailto:zhoresh@gmail.com> wrote:
>
> > On 2010/03/23 13:18:39, Paul Lindner wrote:
> >
> >> A different way of dealing with
> >> https://issues.apache.org/jira/browse/SHINDIG-1283
> >>
> >
> > The Jira indicates the usage of ConcurrentHashMap which supposedly not
> > required to use synchronize. Wouldn't that be a better way then using
> > synchronized and copy the map for every change?
> >
> >
> >
> > http://codereview.appspot.com/669043/show
> >
>
Actually I thought that the approach that Paul has suggested is to allow the read ...
14 years, 1 month ago
(2010-03-23 23:47:01 UTC)
#6
Actually I thought that the approach that Paul has suggested is to allow the
read for the featureMap to make sure when new map is created, other threads
could get the latest instance of it (the proposed change to replace creating new
list to returning featureMap key set instead).
My goal was to eliminate a bunch of arraylist creations on read-only methods by using ...
14 years, 1 month ago
(2010-03-24 00:09:32 UTC)
#7
My goal was to eliminate a bunch of arraylist creations on read-only methods by
using immutable data structures internally. As you can see it was a bit
challenging.
Instead we might want to eliminate the optional injection of
@Named("shindig.features.default") String featureFiles
Move it to the constructor, make register() private (or protected?) and be done
with it, then no worries about concurrent access. This is what I'd prefer, let
Singletons be Singletons.
Is anyone subclassing this, would this be a big problem?
On Mar 23, 2010, at 4:47 PM, henry.saputra@gmail.com wrote:
> Actually I thought that the approach that Paul has suggested is to allow
> the read for the featureMap to make sure when new map is created, other
> threads could get the latest instance of it (the proposed change to
> replace creating new list to returning featureMap key set instead).
>
>
> http://codereview.appspot.com/669043/show
http://codereview.appspot.com/669043/diff/9001/10002 File java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java (left): http://codereview.appspot.com/669043/diff/9001/10002#oldcode153 java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java:153: connectDependencyGraph(); Where is this check gone to?
14 years, 1 month ago
(2010-03-24 20:52:21 UTC)
#10
http://codereview.appspot.com/669043/diff/9001/10002 File java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java (left): http://codereview.appspot.com/669043/diff/9001/10002#oldcode153 java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java:153: connectDependencyGraph(); On 2010/03/24 20:52:22, zhoresh wrote: > Where is ...
14 years, 1 month ago
(2010-03-24 21:00:08 UTC)
#11
http://codereview.appspot.com/669043/diff/9001/10002
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java
(left):
http://codereview.appspot.com/669043/diff/9001/10002#oldcode153
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java:153:
connectDependencyGraph();
On 2010/03/24 20:52:22, zhoresh wrote:
> Where is this check gone to?
This moves to the main constructor. This allows for a better separation of
concerns. The register method generates the featureMap, and the dependency
graph generation and cache clearing move to up a level. This is possible since
we can guarantee that register() is called only once per object.
Issue 669043: SHINDIG-1283 FeatureRegistry.featureMap concurrent access
Created 14 years, 1 month ago by Paul Lindner
Modified 14 years, 1 month ago
Reviewers: shindig.remailer_gmail.com, zhoresh
Base URL:
Comments: 4