Skip to content

Commit

Permalink
Merge pull request #535 from hamnis/tickwheel-alive
Browse files Browse the repository at this point in the history
Add package private isAlive and specific Exception type
  • Loading branch information
rossabaker authored May 25, 2021
2 parents 4d8fed8 + f22b1f7 commit 67db19e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.http4s.blaze.util

import java.util.concurrent.atomic.AtomicReference

import scala.annotation.tailrec
import scala.util.control.NonFatal
import scala.concurrent.ExecutionContext
Expand Down Expand Up @@ -77,6 +76,8 @@ class TickWheelExecutor(wheelSize: Int = DefaultWheelSize, val tick: Duration =
def shutdown(): Unit =
alive = false

private[http4s] def isAlive = alive

/** Schedule the `Runnable` on the [[TickWheelExecutor]]
*
* Execution is performed on the [[TickWheelExecutor]]s thread, so only extremely small
Expand Down Expand Up @@ -127,7 +128,7 @@ class TickWheelExecutor(wheelSize: Int = DefaultWheelSize, val tick: Duration =
Cancelable.NoopCancel
}
}
else sys.error("TickWheelExecutor is shutdown")
else throw TickWheelExecutor.AlreadyShutdownException

// Deals with appending and removing tasks from the buckets
private def handleTasks(): Unit = {
Expand Down Expand Up @@ -273,6 +274,7 @@ class TickWheelExecutor(wheelSize: Int = DefaultWheelSize, val tick: Duration =
}

object TickWheelExecutor {
object AlreadyShutdownException extends RuntimeException("TickWheelExecutor is shutdown")

/** Default size of the hash wheel */
val DefaultWheelSize = 512
Expand Down

0 comments on commit 67db19e

Please sign in to comment.