File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
modules/options/src/main/scala/scala/build/internal Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,19 @@ import scala.concurrent.duration.Duration
6
6
import scala .concurrent .{Await , ExecutionContext , Future }
7
7
import scala .io .StdIn
8
8
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
+ */
9
22
object StdInConcurrentReader {
10
23
private implicit val ec : ExecutionContext = ExecutionContext .global
11
24
private val readLineFuture : AtomicReference [Future [Option [String ]]] =
You can’t perform that action at this time.
0 commit comments