Initial commit
This commit is contained in:
102
sources/com/tencent/bugly/proguard/w.java
Normal file
102
sources/com/tencent/bugly/proguard/w.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.tencent.bugly.proguard;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/* compiled from: BUGLY */
|
||||
/* loaded from: classes.dex */
|
||||
public final class w {
|
||||
private static final AtomicInteger a = new AtomicInteger(1);
|
||||
private static w b;
|
||||
private ScheduledExecutorService c;
|
||||
|
||||
protected w() {
|
||||
this.c = null;
|
||||
this.c = Executors.newScheduledThreadPool(3, new ThreadFactory(this) { // from class: com.tencent.bugly.proguard.w.1
|
||||
@Override // java.util.concurrent.ThreadFactory
|
||||
public final Thread newThread(Runnable runnable) {
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.setName("BuglyThread-" + w.a.getAndIncrement());
|
||||
return thread;
|
||||
}
|
||||
});
|
||||
ScheduledExecutorService scheduledExecutorService = this.c;
|
||||
if (scheduledExecutorService == null || scheduledExecutorService.isShutdown()) {
|
||||
x.d("[AsyncTaskHandler] ScheduledExecutorService is not valiable!", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized w a() {
|
||||
w wVar;
|
||||
synchronized (w.class) {
|
||||
if (b == null) {
|
||||
b = new w();
|
||||
}
|
||||
wVar = b;
|
||||
}
|
||||
return wVar;
|
||||
}
|
||||
|
||||
public final synchronized void b() {
|
||||
if (this.c != null && !this.c.isShutdown()) {
|
||||
x.c("[AsyncTaskHandler] Close async handler.", new Object[0]);
|
||||
this.c.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
public final synchronized boolean c() {
|
||||
boolean z;
|
||||
if (this.c != null) {
|
||||
z = this.c.isShutdown() ? false : true;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public final synchronized boolean a(Runnable runnable, long j) {
|
||||
if (!c()) {
|
||||
x.d("[AsyncTaskHandler] Async handler was closed, should not post task.", new Object[0]);
|
||||
return false;
|
||||
}
|
||||
if (runnable == null) {
|
||||
x.d("[AsyncTaskHandler] Task input is null.", new Object[0]);
|
||||
return false;
|
||||
}
|
||||
if (j <= 0) {
|
||||
j = 0;
|
||||
}
|
||||
x.c("[AsyncTaskHandler] Post a delay(time: %dms) task: %s", Long.valueOf(j), runnable.getClass().getName());
|
||||
try {
|
||||
this.c.schedule(runnable, j, TimeUnit.MILLISECONDS);
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
if (com.tencent.bugly.b.c) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final synchronized boolean a(Runnable runnable) {
|
||||
if (!c()) {
|
||||
x.d("[AsyncTaskHandler] Async handler was closed, should not post task.", new Object[0]);
|
||||
return false;
|
||||
}
|
||||
if (runnable == null) {
|
||||
x.d("[AsyncTaskHandler] Task input is null.", new Object[0]);
|
||||
return false;
|
||||
}
|
||||
x.c("[AsyncTaskHandler] Post a normal task: %s", runnable.getClass().getName());
|
||||
try {
|
||||
this.c.execute(runnable);
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
if (com.tencent.bugly.b.c) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user