/// <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();
}
}