Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (26 sloc) 1.017 kb
package sbt
import java.io.Writer
final class DeferredWriter(make: => Writer) extends Writer
{
private[this] var opened = false
private[this] var delegate0: Writer = _
private[this] def delegate: Writer = synchronized {
if(delegate0 eq null) {
delegate0 = make
opened = true
}
delegate0
}
override def close() = synchronized {
if(opened) delegate0.close()
}
override def append(c: Char): Writer = delegate.append(c)
override def append(csq: CharSequence): Writer = delegate.append(csq)
override def append(csq: CharSequence, start: Int, end: Int): Writer = delegate.append(csq, start, end)
override def flush() = delegate.flush()
override def write(cbuf: Array[Char]) = delegate.write(cbuf)
override def write(cbuf: Array[Char], off: Int, len: Int): Unit = delegate.write(cbuf, off, len)
override def write(c: Int): Unit = delegate.write(c)
override def write(s: String): Unit = delegate.write(s)
override def write(s: String, off: Int, len: Int): Unit = delegate.write(s, off, len)
}
Jump to Line
Something went wrong with that request. Please try again.