mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-09 15:12:26 -04:00
Rename ReportedPeer to Peer
This commit is contained in:
parent
586d9cdcfd
commit
6daf959f78
12 changed files with 157 additions and 113 deletions
|
@ -48,7 +48,7 @@ public class Log {
|
|||
rollingPolicy.start();
|
||||
|
||||
triggeringPolicy = new SizeBasedTriggeringPolicy();
|
||||
triggeringPolicy.setMaxFileSize("1MB");
|
||||
triggeringPolicy.setMaxFileSize("10MB");
|
||||
triggeringPolicy.start();
|
||||
|
||||
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
|
||||
|
@ -63,7 +63,7 @@ public class Log {
|
|||
|
||||
logbackLogger = loggerContext.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||
//TODO for now use always trace
|
||||
logbackLogger.setLevel(useDetailedLogging ? Level.INFO : Level.INFO);
|
||||
logbackLogger.setLevel(useDetailedLogging ? Level.TRACE : Level.INFO);
|
||||
// logbackLogger.setLevel(useDetailedLogging ? Level.TRACE : Level.DEBUG);
|
||||
logbackLogger.addAppender(appender);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* We simulate a global frame rate timer similar to FXTimer to avoid creation of threads for each timer call.
|
||||
|
@ -16,26 +17,30 @@ public class FrameRateTimer implements Timer, Runnable {
|
|||
private Runnable runnable;
|
||||
private long startTs;
|
||||
private boolean isPeriodically;
|
||||
private String uid = UUID.randomUUID().toString();
|
||||
private volatile boolean stopped;
|
||||
|
||||
public FrameRateTimer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if ((currentTimeMillis - startTs) >= interval) {
|
||||
runnable.run();
|
||||
if (isPeriodically)
|
||||
startTs = currentTimeMillis;
|
||||
else
|
||||
stop();
|
||||
if (!stopped) {
|
||||
try {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if ((currentTimeMillis - startTs) >= interval) {
|
||||
runnable.run();
|
||||
if (isPeriodically)
|
||||
startTs = currentTimeMillis;
|
||||
else
|
||||
stop();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
log.error(t.getMessage());
|
||||
t.printStackTrace();
|
||||
stop();
|
||||
throw t;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
log.error(t.getMessage());
|
||||
t.printStackTrace();
|
||||
stop();
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +65,24 @@ public class FrameRateTimer implements Timer, Runnable {
|
|||
|
||||
@Override
|
||||
public void stop() {
|
||||
stopped = true;
|
||||
MasterTimer.removeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof FrameRateTimer)) return false;
|
||||
|
||||
FrameRateTimer that = (FrameRateTimer) o;
|
||||
|
||||
return !(uid != null ? !uid.equals(that.uid) : that.uid != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return uid != null ? uid.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,16 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
public class MasterTimer {
|
||||
private final static Logger log = LoggerFactory.getLogger(MasterTimer.class);
|
||||
private static final java.util.Timer timer = new java.util.Timer();
|
||||
public static long FRAME_INTERVAL_MS = 16;
|
||||
// frame rate of 60 fps is about 16 ms but we don't need such a short interval, 100 ms should be good enough
|
||||
public static final long FRAME_INTERVAL_MS = 100;
|
||||
|
||||
static {
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
listeners.stream().forEach(UserThread::execute);
|
||||
UserThread.execute(() -> listeners.stream().forEach(Runnable::run));
|
||||
}
|
||||
}, FRAME_INTERVAL_MS, FRAME_INTERVAL_MS); // frame rate of 60 fps is about 16 ms
|
||||
}, FRAME_INTERVAL_MS, FRAME_INTERVAL_MS);
|
||||
}
|
||||
|
||||
private static Set<Runnable> listeners = new CopyOnWriteArraySet<>();
|
||||
|
@ -30,6 +31,4 @@ public class MasterTimer {
|
|||
public static void removeListener(Runnable runnable) {
|
||||
listeners.remove(runnable);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue