| 3 | import androidx.annotation.Keep |
| 4 | |
| 5 | @Keep |
| 6 | class ValdiThread(name: String, val ptr: Long): Runnable { |
| 7 | |
| 8 | private val thread = Thread(this, name) |
| 9 | |
| 10 | var qosClass: QoSClass = QoSClass.NORMAL |
| 11 | set(value) { |
| 12 | field = value |
| 13 | thread.priority = value.toThreadPriority() |
| 14 | } |
| 15 | |
| 16 | fun start() { |
| 17 | thread.start() |
| 18 | } |
| 19 | |
| 20 | @Keep |
| 21 | fun join() { |
| 22 | try { |
| 23 | thread.join() |
| 24 | } catch (interrupted: InterruptedException) {} |
| 25 | } |
| 26 | |
| 27 | @Keep |
| 28 | fun updateQoS(qosClassValue: Int) { |
| 29 | this.qosClass = QoSClass.fromValue(qosClassValue) |
| 30 | } |
| 31 | |
| 32 | override fun run() { |
| 33 | nativeThreadEntryPoint(ptr) |
| 34 | } |
| 35 | |
| 36 | companion object { |
| 37 | @Keep |
| 38 | @JvmStatic |
| 39 | fun start(name: String, qosClassValue: Int, ptr: Long): ValdiThread { |
| 40 | val qosClass = QoSClass.fromValue(qosClassValue) |
| 41 | val thread = ValdiThread(name, ptr) |
| 42 | thread.qosClass = qosClass |
| 43 | thread.start() |
| 44 | return thread |
| 45 | } |
| 46 | |
| 47 | @JvmStatic |
| 48 | private external fun nativeThreadEntryPoint(ptr: Long) |
| 49 | } |
| 50 | |
| 51 | } |
no test coverage detected