@@ -10,7 +10,6 @@ import java.io.InputStreamReader
10
10
import java .io .OutputStreamWriter
11
11
import java .io .BufferedWriter
12
12
import java .io .BufferedReader
13
- import scala .sys .process ._
14
13
import scala .concurrent .SyncVar
15
14
16
15
import model ._
@@ -70,9 +69,9 @@ class DotRunner(settings: doc.Settings) {
70
69
71
70
class DotProcess (settings : doc.Settings ) {
72
71
73
- @
F5C2
volatile var error : Boolean = false // signal an error
74
- val inputString = new SyncVar [String ] // used for the dot process input
75
- val outputString = new SyncVar [String ] // used for the dot process output
72
+ @ volatile var error : Boolean = false // signal an error
73
+ val inputString = new SyncVar [String ] // used for the dot process input
74
+ val outputString = new SyncVar [String ] // used for the dot process output
76
75
val errorBuffer : StringBuffer = new StringBuffer () // buffer used for both dot process error console AND logging
77
76
78
77
// set in only one place, in the main thread
@@ -86,12 +85,20 @@ class DotProcess(settings: doc.Settings) {
86
85
templateInput = input
87
86
88
87
try {
89
-
90
88
// process creation
91
89
if (process == null ) {
92
- val procIO = new ProcessIO (inputFn(_), outputFn(_), errorFn(_))
93
- val processBuilder : ProcessBuilder = Seq (settings.docDiagramsDotPath.value, " -Tsvg" )
94
- process = processBuilder.run(procIO)
90
+ val processBuilder = new ProcessBuilder (settings.docDiagramsDotPath.value, " -Tsvg" )
91
+ process = processBuilder.start()
92
+
93
+ def spawn (f : Runnable ): Unit = {
94
+ val thread = new Thread (f)
95
+ thread.setDaemon(true )
96
+ thread.start()
97
+ }
98
+
99
+ spawn { () => inputFn(process.getOutputStream()) }
100
+ spawn { () => outputFn(process.getInputStream()) }
101
+ spawn { () => errorFn(process.getErrorStream()) }
95
102
}
96
103
97
104
// pass the input and wait for the output
0 commit comments