package Ġsz . scaffold . dispatch ers Ċ Ċ import Ġkotlinx . coroutines . Coroutine Dispatcher Ċ import Ġkotlinx . coroutines . as Coroutine Dispatcher Ċ import Ġsz . scaffold . Application Ċ import Ġsz . scaffold . ext . getInt OrElse Ċ import Ġjava . util . concurrent . Fork Join Pool Ċ import Ġjava . util . concurrent . Fork Join Worker Thread Ċ import Ġkotlin . math . max Ċ Ċ // Ċ // ĠCreated Ġby Ġkk Ġon Ġ 2 0 2 0 / 7 / 2 3 . Ċ // Ċ class ĠFork Join Pool Dispatcher Ġ: ĠI Dispatcher Factory Ġ{ ĊĊĠĠĠ Ġval Ġparallel ism : ĠInt Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ ĠApplication . config . getInt OrElse (" app . http Server . dispatcher . parallel ism ", Ġmax ( 1 6 , ĠRuntime . get Runtime (). available Processors ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġbuild (): ĠCor outine Dispatcher Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠFork Join Pool ( parallel ism , ĠThread Factory (), Ġnull , Ġfalse ). as Coroutine Dispatcher () ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠThread Factory Ġ: ĠFork Join Pool . Fork Join Worker Thread Factory Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġnew Thread ( pool : ĠFork Join Pool ?): ĠFork Join Worker Thread Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġthread Ġ= ĠFork Join Pool . default Fork Join Worker Thread Factory . new Thread ( pool ) ĊĠĠĠĠĠĠĠ Ġthread . name Ġ= Ġ" http -${ thread . name }" ĊĠĠĠĠĠĠĠ Ġreturn Ġthread ĊĠĠĠ Ġ} Ċ Ċ }