Created
March 10, 2014 10:13
-
-
Save normanmaurer/9462420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static final Map<Class<?>, Boolean> SHARABLE_CACHE = PlatformDependent.newConcurrentHashMap(); | |
| // Not using volatile because it's used only for a sanity check. | |
| boolean added; | |
| /** | |
| * Return {@code true} if the implementation is {@link Sharable} and so can be added | |
| * to different {@link ChannelPipeline}s. | |
| */ | |
| public boolean isSharable() { | |
| Class<?> clazz = getClass(); | |
| Boolean sharable = SHARABLE_CACHE.get(clazz); | |
| if (sharable == null) { | |
| sharable = clazz.isAnnotationPresent(Sharable.class); | |
| SHARABLE_CACHE.put(clazz, sharable); | |
| } | |
| return sharable; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment