Upgrader
This commit is contained in:
@@ -132,6 +132,7 @@ abstract class Task {
|
||||
fun executor() = TaskExecutor(this)
|
||||
fun executor(taskListener: TaskListener) = TaskExecutor(this).apply { this.taskListener = taskListener }
|
||||
fun start() = executor().start()
|
||||
fun test() = executor().test()
|
||||
fun subscribe(subscriber: Task) = TaskExecutor(with(subscriber)).apply { start() }
|
||||
|
||||
fun subscribe(scheduler: Scheduler = Scheduler.DEFAULT, closure: (AutoTypingMap<String>) -> Unit) = subscribe(task(scheduler, closure))
|
||||
|
||||
@@ -47,6 +47,20 @@ class TaskExecutor(private val task: Task) {
|
||||
})
|
||||
}
|
||||
|
||||
@Throws(InterruptedException::class)
|
||||
fun test(): Boolean {
|
||||
var flag = true
|
||||
val future = Scheduler.NEW_THREAD.schedule {
|
||||
if (!executeTasks(listOf(task))) {
|
||||
taskListener?.onTerminate()
|
||||
flag = false
|
||||
}
|
||||
}
|
||||
workerQueue.add(future)
|
||||
future!!.get()
|
||||
return flag
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the subscription ant interrupt all tasks.
|
||||
*/
|
||||
|
||||
@@ -28,23 +28,23 @@ import java.util.*
|
||||
/**
|
||||
* Represents the operating system.
|
||||
*/
|
||||
enum class OS {
|
||||
enum class OS(val checkedName: String) {
|
||||
/**
|
||||
* Microsoft Windows.
|
||||
*/
|
||||
WINDOWS,
|
||||
WINDOWS("windows"),
|
||||
/**
|
||||
* Linux and Unix like OS, including Solaris.
|
||||
*/
|
||||
LINUX,
|
||||
LINUX("linux"),
|
||||
/**
|
||||
* Mac OS X.
|
||||
*/
|
||||
OSX,
|
||||
OSX("osx"),
|
||||
/**
|
||||
* Unknown operating system.
|
||||
*/
|
||||
UNKNOWN;
|
||||
UNKNOWN("universal");
|
||||
|
||||
companion object {
|
||||
/**
|
||||
|
||||
@@ -75,6 +75,8 @@ class StringVersionNumber internal constructor(val version: String): VersionNumb
|
||||
*/
|
||||
class IntVersionNumber internal constructor(val version: List<Int>): VersionNumber() {
|
||||
|
||||
operator fun get(index: Int) = version[index]
|
||||
|
||||
override fun compareTo(other: VersionNumber): Int {
|
||||
if (other !is IntVersionNumber) return 0
|
||||
val len = minOf(this.version.size, other.version.size)
|
||||
|
||||
Reference in New Issue
Block a user