Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Puller <[email protected]>
  • Loading branch information
zpuller committed Dec 17, 2024
1 parent 82b0d7e commit 2cf6f30
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,14 @@ trait SpillableHandle extends StoreHandle {
* construction, and is immutable.
* @return true if currently spillable, false otherwise
*/
private[spill] def spillable: Boolean = spillLock.synchronized {
approxSizeInBytes > 0 && !spilling
private[spill] def spillable: Boolean = {
if (approxSizeInBytes > 0) {
spillLock.synchronized {
!spilling
}
} else {
false
}
}
}

Expand Down Expand Up @@ -488,21 +494,21 @@ class SpillableDeviceBufferHandle private (
}

override def spill(): Long = {
val spilled = if (!spillable || !setSpilling(true)) {
if (!spillable || !setSpilling(true)) {
0L
} else {
synchronized {
if (host.isEmpty && dev.isDefined) {
val spilled = if (host.isEmpty && dev.isDefined) {
host = Some(SpillableHostBufferHandle.createHostHandleFromDeviceBuff(dev.get))
sizeInBytes
} else {
0L
}
setSpilling(false)
spilled
}
}
// Make sure to only set spilling to false if it was previously set to true
setSpilling(false)
spilled
}

override def close(): Unit = {
Expand Down

0 comments on commit 2cf6f30

Please sign in to comment.