package arm
- Alphabetic
- Public
- All
Type Members
-
trait
CanManage[-R] extends AnyRef
For encapsulating the management logic of a resource.
For encapsulating the management logic of a resource.
Default logic for any
java.lang.AutoClosableis provided by the companion object, which may be imported into current scope as implicits.Other types may be provided in scope by the user. For example
import java.util.concurrent._ import io.tmos.arm.Implicits._ implicit val manager: CanManage[ExecutorService] = new CanManage[ExecutorService] { override def onFinally(pool: ExecutorService): Unit = { pool.shutdown() // Disable new tasks from being submitted try { if (!pool.awaitTermination(10, TimeUnit.SECONDS)) { // wait for normal termination pool.shutdownNow() // force terminate if (!pool.awaitTermination(10, TimeUnit.SECONDS)) // wait for forced termination throw new RuntimeException("ExecutorService did not terminate") } } catch { case _: InterruptedException => pool.shutdownNow() // (Re-)Cancel if current thread also interrupted Thread.currentThread().interrupt() // Preserve interrupt status } } override def onException(r: ExecutorService): Unit = {} } for (manage(executorService) <- Executors.newSingleThreadExecutor.manage) { ... }
- R
the type of the resource to manage
-
class
DefaultManagedResource[R, -S >: R] extends ManagedResource[R]
The default implementation of a ManagedResource.
The default implementation of a ManagedResource.
- R
the type of the resource to pass to the main body
- S
the type of the resource under management
-
trait
ManagedResource[+A] extends AnyRef
A resource that is managed.
A resource that is managed.
Only one implementation is provided currently DefaultManagedResource. Subclasses only need to provide ManagedResource.map
- A
the type of the resource to manage
Value Members
-
object
ArmMethods
Methods for management of a resource.
Methods for management of a resource.
For implicit management see
io.tmos.arm.Implicits. -
object
CanManage
Companion object to the CanManage type trait.
Companion object to the CanManage type trait.
Contains common implementations of CanManage for AutoClosable Resources
-
object
Implicits
Implicit Methods for management of a resource.
Implicit Methods for management of a resource.
For explicit management see
io.tmos.arm.ArmMethods.