Skip to content

Commit

Permalink
THREAD_TRACE 默认开启
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Aug 30, 2024
1 parent b6571da commit 08c8892
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rxlib/src/main/java/org/rx/core/EventPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum EventFlags implements NEnum<EventFlags> {
final int value;
}

StaticEventPublisher STATIC_EVENT_INSTANCE = new StaticEventPublisher();
// StaticEventPublisher STATIC_EVENT_INSTANCE = new StaticEventPublisher();
StaticEventPublisher STATIC_QUIETLY_EVENT_INSTANCE = new StaticEventPublisher() {
@Override
public FlagsEnum<EventFlags> eventFlags() {
Expand Down
3 changes: 1 addition & 2 deletions rxlib/src/main/java/org/rx/core/TimeoutFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ public enum TimeoutFlag implements NEnum<TimeoutFlag> {
NONE(0),
SINGLE(1),
REPLACE(1 << 1),
PERIOD(1 << 2),
THREAD_TRACE(1 << 3);
PERIOD(1 << 2);

final int value;
}
12 changes: 2 additions & 10 deletions rxlib/src/main/java/org/rx/core/WheelTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ class Task<T> implements TimerTask, TimeoutFuture<T> {
flags = TimeoutFlag.NONE.flags();
}
RxConfig conf = RxConfig.INSTANCE;
if (conf.threadPool.traceName != null) {
flags.add(TimeoutFlag.THREAD_TRACE);
}
if (conf.trace.slowMethodElapsedMicros > 0 && ThreadLocalRandom.current().nextInt(0, 100) < conf.threadPool.slowMethodSamplingPercent) {
stackTrace = new Throwable().getStackTrace();
} else {
Expand All @@ -77,10 +74,7 @@ class Task<T> implements TimerTask, TimeoutFuture<T> {
@SneakyThrows
@Override
public synchronized void run(Timeout timeout) throws Exception {
boolean traceFlag = flags.has(TimeoutFlag.THREAD_TRACE);
if (traceFlag) {
ThreadPool.startTrace(traceId);
}
ThreadPool.startTrace(traceId);
ThreadPool.CTX_STACK_TRACE.set(stackTrace != null ? stackTrace : Boolean.TRUE);
try {
future = executor.submit(() -> {
Expand All @@ -97,9 +91,7 @@ public synchronized void run(Timeout timeout) throws Exception {
});
} finally {
ThreadPool.CTX_STACK_TRACE.remove();
if (traceFlag) {
ThreadPool.endTrace();
}
ThreadPool.endTrace();
}
notifyAll();
}
Expand Down

0 comments on commit 08c8892

Please sign in to comment.