Home / Class/ FallbackThreadSet Class — netty Architecture

FallbackThreadSet Class — netty Architecture

Architecture documentation for the FallbackThreadSet class in FastThreadLocalThread.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  670e3e82_866d_03e0_0560_6f40fa2a4d77["FallbackThreadSet"]
  503fa76d_84e6_5577_f000_e71e9d75cfbc["FastThreadLocalThread.java"]
  670e3e82_866d_03e0_0560_6f40fa2a4d77 -->|defined in| 503fa76d_84e6_5577_f000_e71e9d75cfbc
  f4b9840a_73e3_9c58_84c3_3202c658ee65["FallbackThreadSet()"]
  670e3e82_866d_03e0_0560_6f40fa2a4d77 -->|method| f4b9840a_73e3_9c58_84c3_3202c658ee65
  3b1a506e_9004_a3cf_45ac_f08e7950c618["contains()"]
  670e3e82_866d_03e0_0560_6f40fa2a4d77 -->|method| 3b1a506e_9004_a3cf_45ac_f08e7950c618

Relationship Graph

Source Code

common/src/main/java/io/netty/util/concurrent/FastThreadLocalThread.java lines 201–255

    private static final class FallbackThreadSet {
        static final FallbackThreadSet EMPTY = new FallbackThreadSet();
        private static final long EMPTY_VALUE = 0L;

        private final LongLongHashMap map;

        private FallbackThreadSet() {
            this.map = new LongLongHashMap(EMPTY_VALUE);
        }

        private FallbackThreadSet(LongLongHashMap map) {
            this.map = map;
        }

        public boolean contains(long threadId) {
            long key = threadId >>> 6;
            long bit = 1L << (threadId & 63);

            long bitmap = map.get(key);
            return (bitmap & bit) != 0;
        }

        public FallbackThreadSet add(long threadId) {
            long key = threadId >>> 6;
            long bit = 1L << (threadId & 63);

            LongLongHashMap newMap = new LongLongHashMap(map);
            long oldBitmap = newMap.get(key);
            long newBitmap = oldBitmap | bit;
            newMap.put(key, newBitmap);

            return new FallbackThreadSet(newMap);
        }

        public FallbackThreadSet remove(long threadId) {
            long key = threadId >>> 6;
            long bit = 1L << (threadId & 63);

            long oldBitmap = map.get(key);
            if ((oldBitmap & bit) == 0) {
                return this;
            }

            LongLongHashMap newMap = new LongLongHashMap(map);
            long newBitmap = oldBitmap & ~bit;

            if (newBitmap != EMPTY_VALUE) {
                newMap.put(key, newBitmap);
            } else {
                newMap.remove(key);
            }

            return new FallbackThreadSet(newMap);
        }
    }

Frequently Asked Questions

What is the FallbackThreadSet class?
FallbackThreadSet is a class in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/FastThreadLocalThread.java.
Where is FallbackThreadSet defined?
FallbackThreadSet is defined in common/src/main/java/io/netty/util/concurrent/FastThreadLocalThread.java at line 201.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free