Skip to content

Commit 7323222

Browse files
committed
Add scaladoc for StdInConcurrentReader
1 parent 8b57fd5 commit 7323222

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

modules/options/src/main/scala/scala/build/internal/StdInConcurrentReader.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ import scala.concurrent.duration.Duration
66
import scala.concurrent.{Await, ExecutionContext, Future}
77
import scala.io.StdIn
88

9+
/** Allows for reading StdIn concurrently, in a way that it can be interrupted. It was introduced in
10+
* [[https://github.com/VirtusLab/scala-cli/pull/2168 #2168]] to fix input conflicts when watch and
11+
* interactive modes are used together. <br>
12+
*
13+
* Two scenarios are possible when a new process uses [[waitforLine]] to read StdIn:
14+
* - if there is no ongoing reads taking place a future reading StdIn is started and the process
15+
* waits until there's a new input line or until it is interrupted
16+
* - if there is an ongoing read, the process waits for the result of the ongoing future or until
17+
* it is interrupted. <br>
18+
*
19+
* __Effectively, if used in parallel, the potential input is copied and distributed among the
20+
* callers of [[waitForLine]]__
21+
*/
922
object StdInConcurrentReader {
1023
private implicit val ec: ExecutionContext = ExecutionContext.global
1124
private val readLineFuture: AtomicReference[Future[Option[String]]] =

0 commit comments

Comments
 (0)