public virtual void TestInitValue() { LightWeightThreadLocal <object> tl = new LightWeightThreadLocal <object>(_ => TEST_VALUE); System.String str = (System.String)tl.Get(null); Assert.AreEqual(TEST_VALUE, str); }
public virtual void TestDefaultValueWithoutSetting() { // LUCENE-1805: make sure default get returns null, // twice in a row LightWeightThreadLocal <object> ctl = new LightWeightThreadLocal <object>(); Assert.IsNull(ctl.Get(null)); Assert.IsNull(ctl.Get(null)); }
public virtual void TestNullValue() { // Tests that null can be set as a valid value (LUCENE-1805). This // previously failed in get(). LightWeightThreadLocal <object> ctl = new LightWeightThreadLocal <object>(); ctl.Set(null); Assert.IsNull(ctl.Get(null)); }
public void Register(LightWeightThreadLocal <T> parent) { _parents.Add(parent.SelfReference); int localVersion = _localState.LocalVersion; var globalVersion = GlobalVersion; if (localVersion != globalVersion) { // a thread local instance was disposed, let's check // if we need to do cleanup here RemoveDisposedParents(); _localState.LocalVersion = globalVersion; } }