mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
23 lines
514 B
Scala
23 lines
514 B
Scala
// Copyright (c) 2017 PSForever
|
|
package net.psforever
|
|
|
|
class ObjectFinalizedException(msg : String) extends Exception(msg)
|
|
|
|
trait IFinalizable {
|
|
var closed = false
|
|
|
|
def close = {
|
|
closed = true
|
|
}
|
|
|
|
def assertNotClosed = {
|
|
if(closed)
|
|
throw new ObjectFinalizedException(this.getClass.getCanonicalName + ": already finalized. Cannot interact with object")
|
|
}
|
|
|
|
override def finalize() = {
|
|
if(!closed)
|
|
println(this.getClass.getCanonicalName + ": class not closed. memory leaked")
|
|
}
|
|
}
|