Пример #1
0
            public void Register(LightWeightThreadLocal <T> parent)
            {
                parent._globalState.UsedThreads.TryAdd(_localState, null);
                _parents.Add(parent.SelfReference);
                int parentsDisposed = _localState.ParentsDisposed;

                if (parentsDisposed > 0)
                {
                    RemoveDisposedParents();
                    Interlocked.Add(ref _localState.ParentsDisposed, -parentsDisposed);
                }
            }
Пример #2
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;
                }
            }