Skip to content

Commit

Permalink
Make cask multithreaded by default
Browse files Browse the repository at this point in the history
  • Loading branch information
lolgab committed Oct 19, 2024
1 parent cb53455 commit 484011c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion snunit-undertow/src/io/undertow/io/AsyncSenderImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import snunit.*

class AsyncSenderImpl(exchange: HttpServerExchange) extends Sender {
def send(data: String): Unit =
exchange.req.send(StatusCode(exchange.getStatusCode()), data, Headers(exchange.getResponseHeaders().asScala: _*))
exchange.req.send(StatusCode(exchange.getStatusCode()), data, exchange.getResponseHeaders().toSNUnitHeaders)
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ object HttpServerExchange {
override def flush(): Unit = ???

override def close(): Unit = {
exchange.req.send(StatusCode(exchange.state), responseData, Headers(exchange.responseHeaders.asScala: _*))
exchange.req.send(StatusCode(exchange.state), responseData, exchange.responseHeaders.toSNUnitHeaders)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import io.undertow.server._
final class BlockingHandler(handler: HttpHandler) extends HttpHandler {
def handleRequest(exchange: HttpServerExchange): Unit = {
exchange.startBlocking()
handler.handleRequest(exchange)
exchange.endExchange()
scala.concurrent.ExecutionContext.global.execute(() =>
try { handler.handleRequest(exchange) }
finally { exchange.endExchange() }
)
}
}
11 changes: 10 additions & 1 deletion snunit-undertow/src/io/undertow/server/util/HeaderMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ final class HeaderMap private[undertow] (underlying: collection.Map[String, Stri
private lazy val underlyingMutable = underlying.asInstanceOf[scala.collection.mutable.Map[String, String]]

def this() = this(collection.mutable.Map.empty[String, String])
private[undertow] def asScala = underlying.toSeq
private[undertow] def toSNUnitHeaders: snunit.Headers =
val headers = snunit.Headers(underlying.size)
var i = 0
underlying.foreach((k, v) =>
headers.updateName(i, k)
headers.updateValue(i, v)
i += 1
)
headers

def getFirst(headerName: String): String = underlying.getOrElse(headerName, null)
def get(headerName: String): java.util.Collection[String] = {
val l = new java.util.ArrayList[String]()
Expand Down

0 comments on commit 484011c

Please sign in to comment.