Package com.tangosol.util
Class MultiBinaryLongMap.MaskedLongMapHolder
- java.lang.Object
-
- com.tangosol.util.MultiBinaryLongMap.MaskedLongMapHolder
-
- Direct Known Subclasses:
MultiBinaryLongMap.LeftoverLongMapHolder
- Enclosing class:
- MultiBinaryLongMap
protected static class MultiBinaryLongMap.MaskedLongMapHolder extends Object
MaskedLongMapHolder is used to produceMultiBinaryLongMap.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.
-
-
Field Summary
Fields Modifier and Type Field 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 ofreserved
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 Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 wasreserved
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.
-
-
-
Field Detail
-
m_listBLMs
protected List<MultiBinaryLongMap.MaskedBinaryLongMap> m_listBLMs
The list ofreserved
masked BLMs, ordered by increasing shift-position.
-
f_lMaskReserved
protected final long f_lMaskReserved
The bit-mask describing which bits in the underlying BLM representation are reserved (and may not be allocated by this holder).
-
m_lMaskFree
protected long m_lMaskFree
The bit-mask describing which bits in the underlying BLM representation are free.
-
f_lockS
protected final Lock f_lockS
The shared lock used to protected the logical contents of the maps exposed by this MaskedLongMapHolder.
-
f_lockX
protected final Lock f_lockX
The exclusive lock used to protected the logical contents of the maps exposed by this MaskedLongMapHolder.
-
f_blm
protected final BinaryLongMap f_blm
The BinaryLongMap shared by the component masked BLMs.
-
-
Constructor Detail
-
MaskedLongMapHolder
public MaskedLongMapHolder(BinaryLongMap blm, Lock lockSMaster)
Construct a MaskedLongMapHolder backed by the specified blm.- Parameters:
blm
- the BinaryLongMap that the component masked maps are backed bylockSMaster
- the shared master-lock for the MultiBinaryLongMap
-
MaskedLongMapHolder
public MaskedLongMapHolder(BinaryLongMap blm, Lock lockSMaster, long lMaskReserved)
Construct a MaskedLongMapHolder backed by the specified blm with the specified reserved bit-mask.- Parameters:
blm
- the BinaryLongMap that the component masked maps are backed bylockSMaster
- the shared master-lock for the MultiBinaryLongMaplMaskReserved
- the bit-mask representing the reserved bits
-
-
Method Detail
-
getDelegateMap
public BinaryLongMap getDelegateMap()
Return the BinaryLongMap that provides the underlying storage for this MaskedLongMapHolder.- Returns:
- the underlying BinaryLongMap
-
reserveMap
public BinaryLongMap reserveMap(int cBits)
Reserve and return a masked BLM from this MaskedLongMapHolder if available, or null otherwise. Reserved maps must bereleased
when no longer needed.- Parameters:
cBits
- the number of bits to use to store each value- Returns:
- a masked BLM, or null
-
releaseMap
public boolean releaseMap(MultiBinaryLongMap.MaskedBinaryLongMap blm)
Release a masked BLM that wasreserved
from this MaskedLongMapHolder.- Parameters:
blm
- the masked BLM to release- Returns:
- true iff the MaskedLongMapHolder becomes empty as a result
-
isEmpty
public boolean isEmpty()
Return true iff all non-reserved bits are free (not in-use).- Returns:
- true iff all non-reserved bits are free (not in use)
-
instantiateMaskedBinaryLongMap
protected MultiBinaryLongMap.MaskedBinaryLongMap instantiateMaskedBinaryLongMap(int cShift, int cBits)
Factory method for instantiating MaskedBinaryLongMap instances associated with this MaskedLongMapHolder.- Parameters:
cShift
- the shift position of the masked BLMcBits
- the bit-width of values represented by the BLM- Returns:
- a MaskedBinaryLongMap with the specified shift and mask associated with this LongMapHolder (and backed by the underlying BLM)
-
shiftMaskedMap
protected void shiftMaskedMap(MultiBinaryLongMap.MaskedBinaryLongMap blm, int cShiftRight)
Shift the representation of the specified MaskedBinaryLongMap by the specified number of bits to the right.Note: the caller must hold exclusive access to the underlying BLM (and by extension, exclusive access to all derived masked maps).
- Parameters:
blm
- the MaskedBinaryLongMap to shiftcShiftRight
- the number of bits to shift to the right
-
checkRep
protected void checkRep()
Debugging function to check the representational invariant.
-
-