Package org.apache.calcite.util
Class CompoundClosableAllocation
- java.lang.Object
-
- org.apache.calcite.util.CompoundClosableAllocation
-
- All Implemented Interfaces:
ClosableAllocation
,ClosableAllocationOwner
public class CompoundClosableAllocation extends java.lang.Object implements ClosableAllocationOwner
CompoundClosableAllocation represents a collection of ClosableAllocations which share a common lifecycle. It guarantees that allocations are closed in the reverse order in which they were added.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<ClosableAllocation>
allocations
List of owned ClosableAllocation objects.
-
Constructor Summary
Constructors Constructor Description CompoundClosableAllocation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAllocation(ClosableAllocation allocation)
Assigns ownership of a ClosableAllocation to this owner.void
closeAllocation()
Closes this object.boolean
forgetAllocation(ClosableAllocation allocation)
Forgets an allocation without closing it.boolean
hasAllocations()
-
-
-
Field Detail
-
allocations
protected java.util.List<ClosableAllocation> allocations
List of owned ClosableAllocation objects.
-
-
Method Detail
-
addAllocation
public void addAllocation(ClosableAllocation allocation)
Description copied from interface:ClosableAllocationOwner
Assigns ownership of a ClosableAllocation to this owner.- Specified by:
addAllocation
in interfaceClosableAllocationOwner
- Parameters:
allocation
- the ClosableAllocation to take over
-
closeAllocation
public void closeAllocation()
Description copied from interface:ClosableAllocation
Closes this object.- Specified by:
closeAllocation
in interfaceClosableAllocation
-
forgetAllocation
public boolean forgetAllocation(ClosableAllocation allocation)
Forgets an allocation without closing it.- Parameters:
allocation
- the allocation to forget- Returns:
- whether the allocation was known
-
hasAllocations
public boolean hasAllocations()
- Returns:
- whether any allocations remain unclosed
-
-