protected static class MultiBinaryLongMap.MaskedLongMapHolder extends Object
MultiBinaryLongMap.MaskedBinaryLongMap
instances backed by a shared BinaryLongMap. MaskedBinaryLongMap instances
created by this holder are thread-safe and are all protected by the same
shared and exclusive locks.Modifier and Type | Field and Description |
---|---|
protected BinaryLongMap |
f_blm
The BinaryLongMap shared by the component masked BLMs.
|
protected long |
f_lMaskReserved
The bit-mask describing which bits in the underlying BLM
representation are reserved (and may not be allocated by this holder).
|
protected Lock |
f_lockS
The shared lock used to protected the logical contents of the maps
exposed by this MaskedLongMapHolder.
|
protected Lock |
f_lockX
The exclusive lock used to protected the logical contents of the maps
exposed by this MaskedLongMapHolder.
|
protected List<MultiBinaryLongMap.MaskedBinaryLongMap> |
m_listBLMs
The list of
reserved masked BLMs, ordered by
increasing shift-position. |
protected long |
m_lMaskFree
The bit-mask describing which bits in the underlying BLM
representation are free.
|
Constructor and Description |
---|
MaskedLongMapHolder(BinaryLongMap blm,
Lock lockSMaster)
Construct a MaskedLongMapHolder backed by the specified blm.
|
MaskedLongMapHolder(BinaryLongMap blm,
Lock lockSMaster,
long lMaskReserved)
Construct a MaskedLongMapHolder backed by the specified blm with the
specified reserved bit-mask.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkRep()
Debugging function to check the representational invariant.
|
BinaryLongMap |
getDelegateMap()
Return the BinaryLongMap that provides the underlying storage for
this MaskedLongMapHolder.
|
protected MultiBinaryLongMap.MaskedBinaryLongMap |
instantiateMaskedBinaryLongMap(int cShift,
int cBits)
Factory method for instantiating MaskedBinaryLongMap instances
associated with this MaskedLongMapHolder.
|
boolean |
isEmpty()
Return true iff all non-reserved bits are free (not in-use).
|
boolean |
releaseMap(MultiBinaryLongMap.MaskedBinaryLongMap blm)
Release a masked BLM that was
reserved from
this MaskedLongMapHolder. |
BinaryLongMap |
reserveMap(int cBits)
Reserve and return a masked BLM from this MaskedLongMapHolder if
available, or null otherwise.
|
protected void |
shiftMaskedMap(MultiBinaryLongMap.MaskedBinaryLongMap blm,
int cShiftRight)
Shift the representation of the specified MaskedBinaryLongMap by the
specified number of bits to the right.
|
protected List<MultiBinaryLongMap.MaskedBinaryLongMap> m_listBLMs
reserved
masked BLMs, ordered by
increasing shift-position.protected final long f_lMaskReserved
protected long m_lMaskFree
protected final Lock f_lockS
protected final Lock f_lockX
protected final BinaryLongMap f_blm
public MaskedLongMapHolder(BinaryLongMap blm, Lock lockSMaster)
blm
- the BinaryLongMap that the component masked
maps are backed bylockSMaster
- the shared master-lock for the MultiBinaryLongMappublic MaskedLongMapHolder(BinaryLongMap blm, Lock lockSMaster, long lMaskReserved)
blm
- the BinaryLongMap that the component masked
maps are backed bylockSMaster
- the shared master-lock for the MultiBinaryLongMaplMaskReserved
- the bit-mask representing the reserved bitspublic BinaryLongMap getDelegateMap()
public BinaryLongMap reserveMap(int cBits)
released
when no longer needed.cBits
- the number of bits to use to store each valuepublic boolean releaseMap(MultiBinaryLongMap.MaskedBinaryLongMap blm)
reserved
from
this MaskedLongMapHolder.blm
- the masked BLM to releasepublic boolean isEmpty()
protected MultiBinaryLongMap.MaskedBinaryLongMap instantiateMaskedBinaryLongMap(int cShift, int cBits)
cShift
- the shift position of the masked BLMcBits
- the bit-width of values represented by the BLMprotected void shiftMaskedMap(MultiBinaryLongMap.MaskedBinaryLongMap blm, int cShiftRight)
Note: the caller must hold exclusive access to the underlying BLM (and by extension, exclusive access to all derived masked maps).
blm
- the MaskedBinaryLongMap to shiftcShiftRight
- the number of bits to shift to the rightprotected void checkRep()