[2.13.2]开启线程管理功能

This commit is contained in:
renwj
2023-01-06 17:21:12 +08:00
parent 3ade6ef883
commit b9f863383e
8 changed files with 53 additions and 13 deletions

View File

@@ -36,14 +36,14 @@ if (!isAndroidTestBuild()) {
apply plugin: 'apm-plugin'
}
//if (!isAndroidTestBuild()) {
// apply plugin: 'bytex.threadOpt'
// thread_opt {
// enable !isReleaseBuild
// enableInDebug !isReleaseBuild
// logLevel "DEBUG"
// }
//}
if (!isAndroidTestBuild()) {
apply plugin: 'bytex.threadOpt'
thread_opt {
enable !isReleaseBuild
enableInDebug !isReleaseBuild
logLevel "DEBUG"
}
}
if (!isAndroidTestBuild()) {
apply plugin: 'LancetX'

View File

@@ -24,6 +24,6 @@ class APMStartup : AndroidStartup<Boolean?>() {
}
override fun dependenciesByName(): List<String> {
return listOf("com.mogo.launcher.stageone.ARouterStartUp")
return listOf("com.mogo.launcher.stageone.ARouterStartUp", "com.mogo.launcher.stageone.ThreadOptStartup")
}
}

View File

@@ -31,4 +31,8 @@ class ARouterStartUp : AndroidStartup<String>() {
}
override fun waitOnMainThread() = false
override fun dependenciesByName(): List<String>? {
return listOf("com.mogo.launcher.stageone.ThreadOptStartup")
}
}

View File

@@ -105,4 +105,8 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
}
}
override fun dependenciesByName(): List<String> {
return listOf("com.mogo.launcher.stageone.ThreadOptStartup")
}
}

View File

@@ -70,7 +70,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
override fun dependenciesByName(): List<String> {
return listOf(
"com.mogo.launcher.stageone.APMStartup",
"com.mogo.launcher.stageone.ConfigStartUp"
"com.mogo.launcher.stageone.ConfigStartUp",
"com.mogo.launcher.stageone.ThreadOptStartup"
)
}
@@ -367,5 +368,4 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
MogoAiCloudSocketManager.getInstance(context)
.init(context, DebugConfig.getSocketAppId(), lat, lon)
}
}

View File

@@ -0,0 +1,32 @@
package com.mogo.launcher.stageone
import android.content.*
import com.mogo.thread.ext.core.*
import com.mogo.thread.ext.core.config.*
import com.rousetime.android_startup.*
import java.io.*
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.TimeUnit.SECONDS
class ThreadOptStartup: AndroidStartup<Boolean>() {
override fun create(context: Context): Boolean {
ThreadManager
.init(ThreadConfig.Builder()
.maxKeepAliveTime(5, SECONDS)
/*.dump(DumpConfig.Builder()
.dumpLogFilePath(File(context.getExternalFilesDir(null), "thread_dump_log_${ SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.ROOT).format(Date()) }.txt").absolutePath)
.dumpPeriod(5, SECONDS)
.build())*/)
return true
}
override fun callCreateOnMainThread(): Boolean {
return true
}
override fun waitOnMainThread(): Boolean {
return true
}
}

View File

@@ -34,7 +34,7 @@ buildscript {
classpath "com.mogo.cloud:hook:${HOOK_LOG_VERSION}"
classpath "com.mogo.cloud:bizconfig:${BIZCONFIG_VERSION}"
classpath 'com.volcengine:apm_insight_plugin:1.4.1'
// classpath "com.mogo.thread.opt:plg:${THREAD_OPT_VERSION}"
classpath "com.mogo.thread.opt:plg:${THREAD_OPT_VERSION}"
classpath 'com.mogo.cloud:systrace:1.0.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'
classpath 'com.mogo.sticky:service:1.0.8'

View File

@@ -175,4 +175,4 @@ ADAS_DATA_LIB_CHILD_VERSION=.0
# 线程优化版本
THREAD_OPT_VERSION=3.0.2
THREAD_OPT_VERSION=4.0.0