@Test(timeout = 10000) public void testRemoveAll() throws Exception { final AtomicBoolean removed = new AtomicBoolean(); final FastThreadLocal<Boolean> var = new FastThreadLocal<Boolean>() { @Override protected void onRemoval(Boolean value) { removed.set(true); } }; assertThat(var.get(), is(nullValue())); assertThat(FastThreadLocal.size(), is(1)); FastThreadLocal.removeAll(); assertThat(removed.get(), is(true)); assertThat(FastThreadLocal.size(), is(0)); }
public static void removeAll() { InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet(); if (threadLocalMap == null) { return; } try { Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); if (v != null && v != InternalThreadLocalMap.UNSET) { @SuppressWarnings("unchecked") Set<FastThreadLocal<?>> variablesToRemove = (Set<FastThreadLocal<?>>) v; FastThreadLocal<?>[] variablesToRemoveArray = variablesToRemove.toArray(new FastThreadLocal[variablesToRemove.size()]); for (FastThreadLocal<?> tlv: variablesToRemoveArray) { tlv.remove(threadLocalMap); } } } finally { InternalThreadLocalMap.remove(); } }
FastThreadLocal { public static void removeAll() { InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet(); if (threadLocalMap == null) { return; } try { Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); if (v != null && v != InternalThreadLocalMap.UNSET) { @SuppressWarnings("unchecked") Set<FastThreadLocal<?>> variablesToRemove = (Set<FastThreadLocal<?>>) v; FastThreadLocal<?>[] variablesToRemoveArray = variablesToRemove.toArray(new FastThreadLocal[variablesToRemove.size()]); for (FastThreadLocal<?> tlv: variablesToRemoveArray) { tlv.remove(threadLocalMap); } } } finally { InternalThreadLocalMap.remove(); } } }
FastThreadLocal { public static void removeAll() { InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet(); if (threadLocalMap == null) { return; } try { Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); if (v != null && v != InternalThreadLocalMap.UNSET) { @SuppressWarnings("unchecked") Set<FastThreadLocal<?>> variablesToRemove = (Set<FastThreadLocal<?>>) v; FastThreadLocal<?>[] variablesToRemoveArray = variablesToRemove.toArray(new FastThreadLocal[variablesToRemove.size()]); for (FastThreadLocal<?> tlv: variablesToRemoveArray) { tlv.remove(threadLocalMap); } } } finally { InternalThreadLocalMap.remove(); } } FastThreadLocal(); }
FastThreadLocal { public static void removeAll() { InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet(); if (threadLocalMap == null) { return; } try { Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); if (v != null && v != InternalThreadLocalMap.UNSET) { @SuppressWarnings("unchecked") Set<FastThreadLocal<?>> variablesToRemove = (Set<FastThreadLocal<?>>) v; FastThreadLocal<?>[] variablesToRemoveArray = variablesToRemove.toArray(new FastThreadLocal[variablesToRemove.size()]); for (FastThreadLocal<?> tlv: variablesToRemoveArray) { tlv.remove(threadLocalMap); } } } finally { InternalThreadLocalMap.remove(); } } FastThreadLocal(); static void removeAll(); static int size(); static void destroy(); @SuppressWarnings("unchecked") final V get(); @SuppressWarnings("unchecked") final V get(InternalThreadLocalMap threadLocalMap); final void set(V value); final void set(InternalThreadLocalMap threadLocalMap, V value); final boolean isSet(); final boolean isSet(InternalThreadLocalMap threadLocalMap); final void remove(); @SuppressWarnings("unchecked") final void remove(InternalThreadLocalMap threadLocalMap); }
FastThreadLocal { public static void removeAll() { InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet(); if (threadLocalMap == null) { return; } try { Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); if (v != null && v != InternalThreadLocalMap.UNSET) { @SuppressWarnings("unchecked") Set<FastThreadLocal<?>> variablesToRemove = (Set<FastThreadLocal<?>>) v; FastThreadLocal<?>[] variablesToRemoveArray = variablesToRemove.toArray(new FastThreadLocal[variablesToRemove.size()]); for (FastThreadLocal<?> tlv: variablesToRemoveArray) { tlv.remove(threadLocalMap); } } } finally { InternalThreadLocalMap.remove(); } } FastThreadLocal(); static void removeAll(); static int size(); static void destroy(); @SuppressWarnings("unchecked") final V get(); @SuppressWarnings("unchecked") final V get(InternalThreadLocalMap threadLocalMap); final void set(V value); final void set(InternalThreadLocalMap threadLocalMap, V value); final boolean isSet(); final boolean isSet(InternalThreadLocalMap threadLocalMap); final void remove(); @SuppressWarnings("unchecked") final void remove(InternalThreadLocalMap threadLocalMap);  }