tuxji commented on code in PR #879:
URL: https://github.com/apache/daffodil/pull/879#discussion_r1063553569
##########
daffodil-lib/src/main/scala/org/apache/daffodil/util/Coroutines.scala:
##########
@@ -20,10 +20,25 @@
import org.apache.daffodil.exceptions.UnsuppressableException
import java.util.concurrent.ArrayBlockingQueue
+ import java.util.concurrent.Executors
+
+ import scala.concurrent.ExecutionContext
+ import scala.concurrent.Future
import scala.util.Failure
import scala.util.Success
import scala.util.Try
+ object Coroutine {
+ val executionContext = new ExecutionContext {
+ private val threadPool = Executors.newCachedThreadPool()
+ def execute(runnable: Runnable): Unit = threadPool.submit(runnable)
Review Comment:
How is the thread pool eventually closed, or does this executionContext stay
around as long as the program keeps running? What happens to threads after
they finish running? I googled and found this good discussion:
https://stackoverflow.com/questions/949355/executors-newcachedthreadpool-versus-executors-newfixedthreadpool
The cached thread pool closes inactive threads after 60 seconds, so it will
consume no resources when it is not being used. However, the pool has no
protection against denial-of-service attacks since its maximum pool size is set
to Integer.MAX_VALUE. How does Daffodil guarantee that only a small number of
coroutine threads are used at any time?
If safeguards against denial-of-service attacks are needed, please add
comments to key places so that maintainers will be aware of the need to
preserve these safeguards or add new ones.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]