帆软使用的第三方框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

56 lines
1.5 KiB

package com.fr.third.alibaba.ttl.threadpool;
import com.fr.third.alibaba.ttl.TransmittableThreadLocal;
import com.fr.third.alibaba.ttl.TtlRunnable;
import com.fr.third.alibaba.ttl.spi.TtlEnhanced;
import com.fr.third.alibaba.ttl.spi.TtlWrapper;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.Executor;
/**
* {@link TransmittableThreadLocal} Wrapper of {@link Executor},
* transmit the {@link TransmittableThreadLocal} from the task submit time of {@link Runnable}
* to the execution time of {@link Runnable}.
*
* @author Jerry Lee (oldratlee at gmail dot com)
* @since 0.9.0
*/
class ExecutorTtlWrapper implements Executor, TtlWrapper<Executor>, TtlEnhanced {
private final Executor executor;
ExecutorTtlWrapper(@NotNull Executor executor) {
this.executor = executor;
}
@Override
public void execute(@NotNull Runnable command) {
executor.execute(TtlRunnable.get(command));
}
@Override
@NotNull
public Executor unwrap() {
return executor;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ExecutorTtlWrapper that = (ExecutorTtlWrapper) o;
return executor.equals(that.executor);
}
@Override
public int hashCode() {
return executor.hashCode();
}
@Override
public String toString() {
return this.getClass().getName() + " - " + executor.toString();
}
}