You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by ju...@apache.org on 2015/11/25 04:15:11 UTC
incubator-reef git commit: [REEF-1016] Put a lock in
TangImpl.GetDefaultClassHierarchy
Repository: incubator-reef
Updated Branches:
refs/heads/master dd07dc3ef -> 56287fc8a
[REEF-1016] Put a lock in TangImpl.GetDefaultClassHierarchy
JIRA:
[REEF-1016](https://issues.apache.org/jira/browse/REEF-1016)
Pull request:
This closes #683
Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/56287fc8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/56287fc8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/56287fc8
Branch: refs/heads/master
Commit: 56287fc8af44deef233fb2b7aecde120c2a26cfc
Parents: dd07dc3
Author: Mariia Mykhailova <ma...@apache.org>
Authored: Tue Nov 24 17:01:12 2015 -0800
Committer: Julia Wang <ju...@apache.org>
Committed: Tue Nov 24 19:07:57 2015 -0800
----------------------------------------------------------------------
.../Implementations/Tang/TangImpl.cs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/56287fc8/lang/cs/Org.Apache.REEF.Tang/Implementations/Tang/TangImpl.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tang/Implementations/Tang/TangImpl.cs b/lang/cs/Org.Apache.REEF.Tang/Implementations/Tang/TangImpl.cs
index a71a225..1fca1eb 100644
--- a/lang/cs/Org.Apache.REEF.Tang/Implementations/Tang/TangImpl.cs
+++ b/lang/cs/Org.Apache.REEF.Tang/Implementations/Tang/TangImpl.cs
@@ -36,6 +36,7 @@ namespace Org.Apache.REEF.Tang.Implementations.Tang
private static IDictionary<SetValuedKey, ICsClassHierarchy> defaultClassHierarchy = new Dictionary<SetValuedKey, ICsClassHierarchy>();
+ private static object classHierarchyLock = new object();
public IInjector NewInjector()
{
try
@@ -132,11 +133,14 @@ namespace Org.Apache.REEF.Tang.Implementations.Tang
SetValuedKey key = new SetValuedKey(assemblies, parameterParsers);
ICsClassHierarchy ret = null;
- defaultClassHierarchy.TryGetValue(key, out ret);
- if (ret == null)
+ lock (classHierarchyLock)
{
- ret = new ClassHierarchyImpl(assemblies, parameterParsers);
- defaultClassHierarchy.Add(key, ret);
+ defaultClassHierarchy.TryGetValue(key, out ret);
+ if (ret == null)
+ {
+ ret = new ClassHierarchyImpl(assemblies, parameterParsers);
+ defaultClassHierarchy.Add(key, ret);
+ }
}
return ret;
}