mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-03 12:10:22 +00:00
* Move /common/src to /src * Move services to net.psforever package * Move /pslogin to /server
24 lines
531 B
Scala
24 lines
531 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")
|
|
}
|
|
}
|