Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
            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;
                }
            }