summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDico <dico.karssiens@gmail.com>2018-08-26 19:52:41 +0100
committerDico <dico.karssiens@gmail.com>2018-08-26 19:52:41 +0100
commitbaf99dc266ccfd6506d2b6a7a4652fe3cfde5959 (patch)
tree42f5f5a4063c94b2c5b95c06ac708ce70d718f9f
parentaa746d3872601cdced36fa2b8cced3aabb32fcb2 (diff)
Refactor some stuff, make classes that really dont need to be sealed something else
-rw-r--r--src/main/kotlin/io/dico/parcels2/blockvisitor/WorktimeLimiter.kt18
-rw-r--r--src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt2
2 files changed, 10 insertions, 10 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/blockvisitor/WorktimeLimiter.kt b/src/main/kotlin/io/dico/parcels2/blockvisitor/WorktimeLimiter.kt
index 30eaabd..33ac351 100644
--- a/src/main/kotlin/io/dico/parcels2/blockvisitor/WorktimeLimiter.kt
+++ b/src/main/kotlin/io/dico/parcels2/blockvisitor/WorktimeLimiter.kt
@@ -17,22 +17,22 @@ typealias WorkerUpdateLister = Worker.(Double, Long) -> Unit
data class TickWorktimeOptions(var workTime: Int, var tickInterval: Int)
-sealed class WorktimeLimiter {
+interface WorktimeLimiter {
/**
* Submit a [task] that should be run synchronously, but limited such that it does not stall the server
* a bunch
*/
- abstract fun submit(task: TimeLimitedTask): Worker
+ fun submit(task: TimeLimitedTask): Worker
/**
* Get a list of all workers
*/
- abstract val workers: List<Worker>
+ val workers: List<Worker>
/**
* Attempts to complete any remaining tasks immediately, without suspension.
*/
- abstract fun completeAllTasks()
+ fun completeAllTasks()
}
interface Timed {
@@ -94,7 +94,7 @@ interface WorkerScope : Timed {
fun setProgress(progress: Double)
}
-private interface WorkerContinuation : Worker, WorkerScope {
+interface WorkerInternal : Worker, WorkerScope {
/**
* Start or resumes the execution of this worker
* and returns true if the worker completed
@@ -113,15 +113,15 @@ private interface WorkerContinuation : Worker, WorkerScope {
* There is a configurable maxiumum amount of milliseconds that can be allocated to all workers together in each server tick
* This object attempts to split that maximum amount of milliseconds equally between all jobs
*/
-class TickWorktimeLimiter(private val plugin: ParcelsPlugin, var options: TickWorktimeOptions) : WorktimeLimiter() {
+class TickWorktimeLimiter(private val plugin: ParcelsPlugin, var options: TickWorktimeOptions) : WorktimeLimiter {
// The currently registered bukkit scheduler task
private var bukkitTask: BukkitTask? = null
// The workers.
- private val _workers = LinkedList<WorkerContinuation>()
+ private val _workers = LinkedList<WorkerInternal>()
override val workers: List<Worker> = _workers
override fun submit(task: TimeLimitedTask): Worker {
- val worker: WorkerContinuation = WorkerImpl(plugin.functionHelper, task)
+ val worker: WorkerInternal = WorkerImpl(plugin.functionHelper, task)
_workers.addFirst(worker)
if (bukkitTask == null) bukkitTask = plugin.functionHelper.scheduleRepeating(0, options.tickInterval) { tickJobs() }
return worker
@@ -166,7 +166,7 @@ class TickWorktimeLimiter(private val plugin: ParcelsPlugin, var options: TickWo
}
private class WorkerImpl(val functionHelper: FunctionHelper,
- val task: TimeLimitedTask) : WorkerContinuation {
+ val task: TimeLimitedTask) : WorkerInternal {
override var job: Job? = null; private set
override val elapsedTime
diff --git a/src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt b/src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt
index 33314aa..0aa4ba0 100644
--- a/src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt
+++ b/src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt
@@ -11,7 +11,7 @@ import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.statements.UpdateBuilder
import java.util.UUID
-sealed class IdTransactionsTable<TableT : IdTransactionsTable<TableT, QueryObj>, QueryObj>(tableName: String, columnName: String)
+abstract class IdTransactionsTable<TableT : IdTransactionsTable<TableT, QueryObj>, QueryObj>(tableName: String, columnName: String)
: Table(tableName) {
val id = integer(columnName).autoIncrement().primaryKey()