- public class Debugger {
-
- public Map<AsyncBarrierImpl, String> infos = new HashMap<>();
-
- public synchronized void inc(AsyncBarrierImpl id, String info) {
- if (id == null)
- return;
- String exist = infos.get(id);
- if (exist != null)
- throw new IllegalStateException("Already existing info " + id + " " + info);
- infos.put(id, exist);
- }
-
- public synchronized void dec(AsyncBarrierImpl id) {
- if (id == null)
- return;
- String exist = infos.get(id);
- if (exist == null) {
- System.err.println("No data for " + id);
- } else {
- infos.remove(id);
- }
- }
-
- @Override
- public synchronized String toString() {
- StringBuilder b = new StringBuilder();
- for (String s : infos.values()) {
- b.append("info " + s + "\r\n");
- }
- return b.toString();
- }
-
- public boolean isEmpty() {
- return infos.isEmpty();
- }
-
- }