Scalax
|
|
scalax/control/ManagedResource.scala
]
abstract
class
ManagedResource[+A]
extends
AnyRefdef fileReader(f : String) = ManagedResource(new FileReader(f)) // Print the first character of a file for(in <- fileReader("/etc/passwd")) println(in.read().toChar)
Type Summary | |
abstract type
|
Handle |
Method Summary | |
def
|
acquireFor
[B](f : (A) => B) : B
Acquires the resource for the duration of the supplied function.
|
def
|
and [B](that : ManagedResource[B]) : ManagedResource[(A, B)] |
def
|
flatMap [B](f : (A) => B) : B |
def
|
foreach (f : (A) => Unit) : Unit |
def
|
map [B](f : (A) => B) : B |
abstract def
|
translate
(v : Handle) : A
Should be implemented to translate a Handle into the desired resource
type.
|
abstract def
|
unsafeClose
(v : Handle) : Unit
Should be implemented to dispose of the managed resource. This will be
called automatically when the ManagedResource is used in a
for-comprehension.
|
def
|
unsafeCloseIgnoringException
(v : Handle) : Unit
Close ignoring Exception, but not any Throwable.
|
def
|
unsafeCloseQuietly (v : Handle) : Unit |
abstract def
|
unsafeOpen
: Handle
Should be implemented to acquire the managed resource. Clients are
discouraged from calling this method directly, as the returned resource
must be disposed of manually.
|
Methods inherited from AnyRef | |
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Type Details |
Method Details |
abstract
def
unsafeOpen : Handle
def
and[B](that : ManagedResource[B]) : ManagedResource[(A, B)]
Scalax
|
|