Top Description Fields Constructors Methods
org.jruby

public Class FlagRegistry

extends Object
Class Inheritance
Imports
java.util.BitSet, .HashMap, .Map

This class serves as a registry of all bit flags we use on JRuby objects. In order to maximally use our bit flags and prevent overlap between ancestors and dependents, this class registers flags on a first-come, first-served basis using previous flags registered for ancestor classes as a base line for new flags in a descendant. Because of the first-come, first-served nature, the most general types will need to register their flags first. This guarantees all bit flags from the progenitor on down will be packed tightly while avoiding overlaps.

Field Summary

Modifier and TypeField and Description
private final Map<Class<T>, Integer>
private final Map<Class<T>, BitSet>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private boolean
flagsAreValid(Class<T> klass, int bitIndex)

public synchronized int

Returns:

an integer with the new flag bit set
newFlag
(Class<T>
the class for which to register a new flag
klass
)

Register a new flag for the given class.

public synchronized void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentShiftback to summary
private final Map<Class<T>, Integer> currentShift
registryback to summary
private final Map<Class<T>, BitSet> registry

Constructor Detail

FlagRegistryback to summary
public FlagRegistry()

Method Detail

flagsAreValidback to summary
private boolean flagsAreValid(Class<T> klass, int bitIndex)
newFlagback to summary
public synchronized int newFlag(Class<T> klass)

Register a new flag for the given class. The bit index for the new flag will be calculated at runtime, by walking parent classes and looking for previously-registered flags. Ancestors should register all their flags before descendants (which means they should not be registered in a static initializer unless the parent is known to have fully run its own static initializers).

Parameters
klass:Class<T>

the class for which to register a new flag

Returns:int

an integer with the new flag bit set

printFlagsback to summary
public synchronized void printFlags()