# HG changeset patch # User Mario Torre # Date 1418646181 -3600 # Node ID d8140bc6ddb5ba588248a6145994651b055c153f # Parent 00b472cd9101c070593120a66f7f12a733bcdc96 Remove locking and implement fail fast for thread monitor review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-December/012285.html reviewed-by: jerboaa diff -r 00b472cd9101 -r d8140bc6ddb5 thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableController.java --- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableController.java Mon Dec 15 13:23:00 2014 +0100 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableController.java Mon Dec 15 13:23:01 2014 +0100 @@ -54,6 +54,8 @@ private ThreadTableView threadTableView; private ThreadCollector collector; + private volatile boolean stopLooping; + public ThreadTableController(ThreadTableView threadTableView, ThreadCollector collector, Timer timer) @@ -64,6 +66,16 @@ timer.setAction(new ThreadTableControllerAction()); } + @Override + protected void onViewVisible() { + stopLooping = false; + } + + @Override + protected void onViewHidden() { + stopLooping = true; + } + private class ThreadTableControllerAction implements Runnable { private ThreadResultHandler handler; @@ -93,8 +105,8 @@ } if (lastSession == null || !session.get().equals(lastSession.get())) { - // since we only visualise one sessions at a time and this - // is a new session needs, let's clear the view + // since we only visualise one session at a time and this is + // a new session, let's clear the view resetState(); } lastSession = session; @@ -166,7 +178,8 @@ threadTableView.display(bean); - return true; + boolean _stopLooping = stopLooping; + return !_stopLooping; } } diff -r 00b472cd9101 -r d8140bc6ddb5 thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineController.java --- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineController.java Mon Dec 15 13:23:00 2014 +0100 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineController.java Mon Dec 15 13:23:01 2014 +0100 @@ -57,9 +57,7 @@ private ThreadTimelineView view; private ThreadCollector collector; - private static final String lock = new String("ThreadTimelineController"); - - private boolean requestClear; + private volatile boolean stopLooping; public ThreadTimelineController(ThreadTimelineView view, ThreadCollector collector, @@ -95,46 +93,52 @@ @Override public void run() { - - synchronized (lock) { + // FIXME: show only the last sessions for now, support for + // filtering over sessions will come later + SessionID session = collector.getLastThreadSession(); + if (session == null) { + // ok, no data, let's skip this round + return; + } - // FIXME: show only the last sessions for now, support for - // filtering over sessions will come later - SessionID session = collector.getLastThreadSession(); - if (session == null) { - // ok, no data, let's skip this round - return; - } - - if (lastSession == null || - !session.get().equals(lastSession.get())) - { - // since we only visualise one sessions at a time and this - // is a new session needs, let's clear the view - resetState(); - } - lastSession = session; + if (lastSession == null || + !session.get().equals(lastSession.get())) + { + // since we only visualise one session at a time and this is + // a new session, let's clear the view + resetState(); + } + lastSession = session; - // get the full range of known timelines per vm - Range totalRange = collector.getThreadRange(session); - if (totalRange == null) { - // this just means we don't have any data yet - return; - } + // get the full range of known timelines per vm + Range totalRange = collector.getThreadRange(session); + if (totalRange == null) { + // this just means we don't have any data yet + return; + } + + if (!totalRange.equals(lastRange)) { + view.setTotalRange(totalRange); + } + lastRange = totalRange; + + range = new Range<>(lastUpdate, totalRange.getMax()); + lastUpdate = totalRange.getMax(); - if (!totalRange.equals(lastRange)) { - view.setTotalRange(totalRange); - } - lastRange = totalRange; + collector.getThreadStates(session, + threadStateResultHandler, + range); + } + } - range = new Range<>(lastUpdate, totalRange.getMax()); - lastUpdate = totalRange.getMax(); + @Override + protected void onViewVisible() { + stopLooping = false; + } - collector.getThreadStates(session, - threadStateResultHandler, - range); - } - } + @Override + protected void onViewHidden() { + stopLooping = true; } private class ThreadStateResultHandler implements ResultHandler { @@ -161,7 +165,8 @@ TimelineProbe probe = TimelineFactory.createTimelineProbe(state); view.addProbe(info, probe); - return true; + boolean _stopLooping = stopLooping; + return !_stopLooping; } } } diff -r 00b472cd9101 -r d8140bc6ddb5 thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/timeline/RangeComponent.java --- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/timeline/RangeComponent.java Mon Dec 15 13:23:00 2014 +0100 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/timeline/RangeComponent.java Mon Dec 15 13:23:01 2014 +0100 @@ -49,6 +49,7 @@ public RangeComponent(RangedTimelineProbe info) { this.info = info; + setOpaque(false); } public RangedTimelineProbe getInfo() {