GetIndexedVariable() private method

private GetIndexedVariable ( int index ) : object
index int
return object
Example #1
0
        /// <summary>
        ///     Removes all {@link FastThreadLocal} variables bound to the current thread.  This operation is useful when you
        ///     are in a container environment, and you don't want to leave the thread local variables in the threads you do not
        ///     manage.
        /// </summary>
        public static void RemoveAll()
        {
            InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.GetIfSet();

            if (threadLocalMap == null)
            {
                return;
            }

            try
            {
                object v = threadLocalMap.GetIndexedVariable(VariablesToRemoveIndex);
                if (v != null && v != InternalThreadLocalMap.Unset)
                {
                    var variablesToRemove = (HashSet <FastThreadLocal>)v;
                    foreach (FastThreadLocal tlv in variablesToRemove) // todo: do we need to make a snapshot?
                    {
                        tlv.Remove(threadLocalMap);
                    }
                }
            }
            finally
            {
                InternalThreadLocalMap.Remove();
            }
        }
Example #2
0
        protected static void RemoveFromVariablesToRemove(InternalThreadLocalMap threadLocalMap,
            FastThreadLocal variable)
        {
            object v = threadLocalMap.GetIndexedVariable(VariablesToRemoveIndex);

            if (v == InternalThreadLocalMap.Unset || v == null)
            {
                return;
            }

            var variablesToRemove = (HashSet<FastThreadLocal>) v;
            variablesToRemove.Remove(variable);
        }
Example #3
0
        protected static void RemoveFromVariablesToRemove(InternalThreadLocalMap threadLocalMap, FastThreadLocal variable)
        {
            object v = threadLocalMap.GetIndexedVariable(VariablesToRemoveIndex);

            if (v == InternalThreadLocalMap.Unset || v == null)
            {
                return;
            }

            var variablesToRemove = (HashSet <FastThreadLocal>)v;

            variablesToRemove.Remove(variable);
        }
Example #4
0
        protected static void AddToVariablesToRemove(InternalThreadLocalMap threadLocalMap, FastThreadLocal variable)
        {
            object v = threadLocalMap.GetIndexedVariable(VariablesToRemoveIndex);
            HashSet<FastThreadLocal> variablesToRemove;
            if (v == InternalThreadLocalMap.Unset || v == null)
            {
                variablesToRemove = new HashSet<FastThreadLocal>();
                    // Collections.newSetFromMap(new IdentityHashMap<FastThreadLocal<?>, Boolean>());
                threadLocalMap.SetIndexedVariable(VariablesToRemoveIndex, variablesToRemove);
            }
            else
            {
                variablesToRemove = (HashSet<FastThreadLocal>) v;
            }

            variablesToRemove.Add(variable);
        }
Example #5
0
        protected static void AddToVariablesToRemove(InternalThreadLocalMap threadLocalMap, FastThreadLocal variable)
        {
            object v = threadLocalMap.GetIndexedVariable(VariablesToRemoveIndex);
            HashSet <FastThreadLocal> variablesToRemove;

            if (v == InternalThreadLocalMap.Unset || v == null)
            {
                variablesToRemove = new HashSet <FastThreadLocal>(); // Collections.newSetFromMap(new IdentityHashMap<FastThreadLocal<?>, Boolean>());
                threadLocalMap.SetIndexedVariable(VariablesToRemoveIndex, variablesToRemove);
            }
            else
            {
                variablesToRemove = (HashSet <FastThreadLocal>)v;
            }

            variablesToRemove.Add(variable);
        }