mirror of
https://github.com/InsanusMokrassar/SauceNaoAPI.git
synced 2025-10-16 04:00:09 +00:00
upmigration
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package dev.inmo.saucenaoapi.utils
|
||||
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
|
||||
interface SauceCloseable {
|
||||
fun close()
|
||||
}
|
||||
|
||||
fun <T> SauceCloseable.use(block: (SauceCloseable) -> T): T = try {
|
||||
block(this)
|
||||
} finally {
|
||||
close()
|
||||
}
|
||||
|
||||
suspend fun <T> SauceCloseable.useSafe(block: suspend (SauceCloseable) -> T): T = try {
|
||||
supervisorScope {
|
||||
block(this@useSafe)
|
||||
}
|
||||
} finally {
|
||||
close()
|
||||
}
|
Reference in New Issue
Block a user