public static Keyword intern(Symbol sym) { Keyword k = null; WeakReference existingRef = _symKeyMap.Get(sym); if (existingRef == null) { if (sym.meta() != null) { sym = (Symbol)sym.withMeta(null); } k = new Keyword(sym); WeakReference wr = new WeakReference(k); wr.Target = k; existingRef = _symKeyMap.PutIfAbsent(sym, wr); } if (existingRef == null) { return(k); } Keyword existingk = (Keyword)existingRef.Target; if (existingk != null) { return(existingk); } // entry died in the interim, do over // let's not get confused, remove it. (else infinite loop). _symKeyMap.Remove(sym); return(intern(sym)); }
/// <summary> /// Construct a namespace with a given name. /// </summary> /// <param name="name">The name.</param> Namespace(Symbol name) : base(name.meta()) { _name = name; _mappings.Set(RT.DEFAULT_IMPORTS); _aliases.Set(RT.map()); }
public static Keyword intern(Symbol sym) { if (sym.meta() != null) { sym = (Symbol)sym.withMeta(null); } // TODO: Analyze this code for improvements Keyword k = new Keyword(sym); //Keyword existing = _symKeyMap.PutIfAbsent(sym, k); //return existing == null ? k : existing; WeakReference wr = new WeakReference(k); wr.Target = k; WeakReference existingRef = _symKeyMap.PutIfAbsent(sym, wr); if (existingRef == null) { return(k); } Keyword existingk = (Keyword)existingRef.Target; if (existingk != null) { return(existingk); } // entry died in the interim, do over // let's not get confused, remove it. (else infinite loop). _symKeyMap.Remove(sym); return(intern(sym)); }
/// <summary> /// Construct a namespace with a given name. /// </summary> /// <param name="name">The name.</param> Namespace(Symbol name) : base(name.meta()) { _name = name; _mappings.Set(RT.DefaultImports); _aliases.Set(RT.map()); }
public static Keyword intern(Symbol sym) { Keyword k = null; WeakReference existingRef = _symKeyMap.Get(sym); if (existingRef == null) { if (sym.meta() != null) sym = (Symbol)sym.withMeta(null); k = new Keyword(sym); WeakReference wr = new WeakReference(k); wr.Target = k; existingRef = _symKeyMap.PutIfAbsent(sym, wr); } if (existingRef == null) return k; Keyword existingk = (Keyword)existingRef.Target; if (existingk != null) return existingk; // entry died in the interim, do over // let's not get confused, remove it. (else infinite loop). _symKeyMap.Remove(sym); return intern(sym); }
public static Keyword intern(Symbol sym) { if (sym.meta() != null) sym = (Symbol)sym.withMeta(null); // TODO: Analyze this code for improvements Keyword k = new Keyword(sym); //Keyword existing = _symKeyMap.PutIfAbsent(sym, k); //return existing == null ? k : existing; WeakReference wr = new WeakReference(k); wr.Target = k; WeakReference existingRef = _symKeyMap.PutIfAbsent(sym, wr); if (existingRef == null) return k; Keyword existingk = (Keyword)existingRef.Target; if (existingk != null) return existingk; // entry died in the interim, do over // let's not get confused, remove it. (else infinite loop). _symKeyMap.Remove(sym); return intern(sym); }