Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package private isAlive and specific Exception type #535

Merged
merged 2 commits into from
May 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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