1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.logging;
12
13 import java.util.ArrayList;
14 import java.util.Collections;
15 import java.util.List;
16
17
18
19
20
21
22 public class PerformanceLogContext {
23
24 private static final PerformanceLogContextt.html#PerformanceLogContext">PerformanceLogContext INSTANCE = new PerformanceLogContext();
25
26
27 private static final ThreadLocal<List<PerformanceLogRecord>> eventRecords = ThreadLocal
28 .withInitial(ArrayList::new);
29
30 private PerformanceLogContext() {
31 }
32
33
34
35
36
37
38 public static PerformanceLogContext getInstance() {
39 return INSTANCE;
40 }
41
42
43
44
45
46
47 public List<PerformanceLogRecord> getEventRecords() {
48 return Collections.unmodifiableList(eventRecords.get());
49 }
50
51
52
53
54
55
56
57 public void addEvent(PerformanceLogRecord record) {
58 eventRecords.get().add(record);
59 }
60
61
62
63
64 public void cleanEvents() {
65 eventRecords.remove();
66 }
67 }