Spaces:
Build error
Build error
File size: 2,004 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
package net.minecraft;
import com.mojang.jtracy.TracyClient;
import com.mojang.jtracy.Zone;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
public record TracingExecutor(ExecutorService service) implements Executor {
public Executor forName(String p_364709_) {
if (SharedConstants.IS_RUNNING_IN_IDE) {
return p_369604_ -> this.service.execute(() -> {
Thread thread = Thread.currentThread();
String s = thread.getName();
thread.setName(p_364709_);
try (Zone zone = TracyClient.beginZone(p_364709_, SharedConstants.IS_RUNNING_IN_IDE)) {
p_369604_.run();
} finally {
thread.setName(s);
}
});
} else {
return (TracyClient.isAvailable() ? p_366279_ -> this.service.execute(() -> {
try (Zone zone = TracyClient.beginZone(p_364709_, SharedConstants.IS_RUNNING_IN_IDE)) {
p_366279_.run();
}
}) : this.service);
}
}
@Override
public void execute(Runnable p_362236_) {
this.service.execute(wrapUnnamed(p_362236_));
}
public void shutdownAndAwait(long p_367055_, TimeUnit p_369186_) {
this.service.shutdown();
boolean flag;
try {
flag = this.service.awaitTermination(p_367055_, p_369186_);
} catch (InterruptedException interruptedexception) {
flag = false;
}
if (!flag) {
this.service.shutdownNow();
}
}
private static Runnable wrapUnnamed(Runnable p_362176_) {
return !TracyClient.isAvailable() ? p_362176_ : () -> {
try (Zone zone = TracyClient.beginZone("task", SharedConstants.IS_RUNNING_IN_IDE)) {
p_362176_.run();
}
};
}
}
|