mirror of
https://github.com/sethm/symon.git
synced 2025-02-11 00:30:45 +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 {
|
public class TraceLog extends JFrame {
|
||||||
|
|
||||||
private FifoRingBuffer<Cpu.CpuState> traceLog;
|
private final FifoRingBuffer<Cpu.CpuState> traceLog;
|
||||||
private JTextArea traceLogTextArea;
|
private final JTextArea traceLogTextArea;
|
||||||
|
|
||||||
private static final Dimension MIN_SIZE = new Dimension(320, 200);
|
private static final Dimension MIN_SIZE = new Dimension(320, 200);
|
||||||
private static final Dimension PREFERRED_SIZE = new Dimension(640, 480);
|
private static final Dimension PREFERRED_SIZE = new Dimension(640, 480);
|
||||||
@ -67,11 +67,15 @@ public class TraceLog extends JFrame {
|
|||||||
* call.
|
* call.
|
||||||
*/
|
*/
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
synchronized (this) {
|
StringBuilder logString = new StringBuilder();
|
||||||
StringBuilder logString = new StringBuilder();
|
|
||||||
|
synchronized(traceLog) {
|
||||||
for (Cpu.CpuState state : traceLog) {
|
for (Cpu.CpuState state : traceLog) {
|
||||||
logString.append(state.toTraceEvent());
|
logString.append(state.toTraceEvent());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized(traceLogTextArea) {
|
||||||
traceLogTextArea.setText(logString.toString());
|
traceLogTextArea.setText(logString.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,8 +84,10 @@ public class TraceLog extends JFrame {
|
|||||||
* Reset the log area.
|
* Reset the log area.
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
synchronized (this) {
|
synchronized(traceLog) {
|
||||||
traceLog.reset();
|
traceLog.reset();
|
||||||
|
}
|
||||||
|
synchronized(traceLogTextArea) {
|
||||||
traceLogTextArea.setText("");
|
traceLogTextArea.setText("");
|
||||||
traceLogTextArea.setEnabled(true);
|
traceLogTextArea.setEnabled(true);
|
||||||
}
|
}
|
||||||
@ -93,7 +99,7 @@ public class TraceLog extends JFrame {
|
|||||||
* @param state The CPU State to append.
|
* @param state The CPU State to append.
|
||||||
*/
|
*/
|
||||||
public void append(Cpu.CpuState state) {
|
public void append(Cpu.CpuState state) {
|
||||||
synchronized(this) {
|
synchronized(traceLog) {
|
||||||
traceLog.push(new Cpu.CpuState(state));
|
traceLog.push(new Cpu.CpuState(state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user