mirror of
https://github.com/sethm/symon.git
synced 2025-02-05 23:30:00 +00:00
finer grained synchronization in TraceLog. Profiling indicates that this speeds up adding log entries quite considerably.
This commit is contained in:
parent
792366fddb
commit
693d1959ac
@ -35,8 +35,8 @@ import java.awt.*;
|
||||
*/
|
||||
public class TraceLog extends JFrame {
|
||||
|
||||
private FifoRingBuffer<Cpu.CpuState> traceLog;
|
||||
private JTextArea traceLogTextArea;
|
||||
private final FifoRingBuffer<Cpu.CpuState> traceLog;
|
||||
private final JTextArea traceLogTextArea;
|
||||
|
||||
private static final Dimension MIN_SIZE = new Dimension(320, 200);
|
||||
private static final Dimension PREFERRED_SIZE = new Dimension(640, 480);
|
||||
@ -67,11 +67,15 @@ public class TraceLog extends JFrame {
|
||||
* call.
|
||||
*/
|
||||
public void refresh() {
|
||||
synchronized (this) {
|
||||
StringBuilder logString = new StringBuilder();
|
||||
StringBuilder logString = new StringBuilder();
|
||||
|
||||
synchronized(traceLog) {
|
||||
for (Cpu.CpuState state : traceLog) {
|
||||
logString.append(state.toTraceEvent());
|
||||
}
|
||||
}
|
||||
|
||||
synchronized(traceLogTextArea) {
|
||||
traceLogTextArea.setText(logString.toString());
|
||||
}
|
||||
}
|
||||
@ -80,8 +84,10 @@ public class TraceLog extends JFrame {
|
||||
* Reset the log area.
|
||||
*/
|
||||
public void reset() {
|
||||
synchronized (this) {
|
||||
synchronized(traceLog) {
|
||||
traceLog.reset();
|
||||
}
|
||||
synchronized(traceLogTextArea) {
|
||||
traceLogTextArea.setText("");
|
||||
traceLogTextArea.setEnabled(true);
|
||||
}
|
||||
@ -93,7 +99,7 @@ public class TraceLog extends JFrame {
|
||||
* @param state The CPU State to append.
|
||||
*/
|
||||
public void append(Cpu.CpuState state) {
|
||||
synchronized(this) {
|
||||
synchronized(traceLog) {
|
||||
traceLog.push(new Cpu.CpuState(state));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user