summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/CompileSocket.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-01 08:27:18 +0000
committerPaul Phillips <paulp@improving.org>2011-02-01 08:27:18 +0000
commitee4e09235afa578a7a33267061179ca338e396c0 (patch)
tree52ff21a786e84f0a3c47ef5666746591301cc47c /src/compiler/scala/tools/nsc/CompileSocket.scala
parentd59d7f928d8a71d73d198690ab5816af3be90d6b (diff)
downloadscala-ee4e09235afa578a7a33267061179ca338e396c0.tar.gz
scala-ee4e09235afa578a7a33267061179ca338e396c0.tar.bz2
scala-ee4e09235afa578a7a33267061179ca338e396c0.zip
Eliminating duplication and trying to outrun ob...
Eliminating duplication and trying to outrun obsolescence in the exciting world of fsc. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/CompileSocket.scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index 19ba822231..1e4b37b3bc 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -16,9 +16,33 @@ import scala.util.control.Exception.catching
import scala.tools.util.StringOps.splitWhere
import scala.sys.process._
+trait CompileSocketShared {
+ def compileSocket: CompileSocket
+ def fscCompile(sock: Socket, args: Seq[String]): Boolean = {
+ var noErrors = true
+
+ sock.applyReaderAndWriter { (in, out) =>
+ out println (compileSocket getPassword sock.getPort())
+ out println (args mkString "\0")
+
+ def loop(): Boolean = in.readLine() match {
+ case null => noErrors
+ case line =>
+ if (compileSocket.errorPattern matcher line matches)
+ noErrors = false
+
+ Console.err println line
+ loop()
+ }
+ try loop()
+ finally sock.close()
+ }
+ }
+}
+
/** This class manages sockets for the fsc offline compiler. */
class CompileSocket {
- protected def compileClient: StandardCompileClient = CompileClient //todo: lazy val
+ protected lazy val compileClient: StandardCompileClient = CompileClient
/** The prefix of the port identification file, which is followed
* by the port number.
@@ -141,9 +165,9 @@ class CompileSocket {
* cannot be established.
*/
def getOrCreateSocket(vmArgs: String, create: Boolean = true): Option[Socket] = {
- // try for 5 seconds
+ // try for 10 seconds
val retryDelay = 100
- val maxAttempts = (5 * 1000) / retryDelay
+ val maxAttempts = (10 * 1000) / retryDelay
def getsock(attempts: Int): Option[Socket] = attempts match {
case 0 => fscError("Unable to establish connection to compilation daemon") ; None
@@ -202,4 +226,5 @@ class CompileSocket {
}
-object CompileSocket extends CompileSocket
+object CompileSocket extends CompileSocket {
+}