com.thoughtworks
The name space for types that models ownership of resources.
杨博 (Yang Bo) <[email protected]>
import com.thoughtworks.raii.ownership._ class TheOwner extends AutoCloseable { private val myStream: this.type Owned InputStream = this.own(new FileInputStream("foo.txt")) def close() = myStream.close() def withMyStream(f: Borrowing[InputStream] => Unit) = { f(myStream) } } val owner = new TheOwner owner.withMyStream { inputStream: Borrowing[InputStream] => println(inputStream.read()) }
The name space for types that models ownership of resources.
Author:
杨博 (Yang Bo) <[email protected]>