diff options
author | Keith Packard <keithp@keithp.com> | 2016-05-10 22:50:23 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-05-11 23:22:15 -0700 |
commit | 2e551e7c5f82a7e35d39e8f73e8e526e5484cd5d (patch) | |
tree | 5609e0511f7905d275022de32960c72a2b43b725 /altosuilib | |
parent | 42021d9fdc6f7a74cc9b20ebf3cf60b4c5f4ea82 (diff) |
altosuilib: Rate limit map loading pacifier updates
Just updating the pacifier was consuming a huge amount of CPU. Update
no more than once every 100ms.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib')
-rw-r--r-- | altosuilib/AltosUIMapPreloadNew.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java index cce07ab4..d6c257e0 100644 --- a/altosuilib/AltosUIMapPreloadNew.java +++ b/altosuilib/AltosUIMapPreloadNew.java @@ -153,8 +153,12 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener double latitude, longitude; + long loader_notify_time; + /* AltosMapLoaderListener interfaces */ public void loader_start(final int max) { + loader_notify_time = System.currentTimeMillis(); + SwingUtilities.invokeLater(new Runnable() { public void run() { pbar.setMaximum(max); @@ -167,6 +171,13 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener } public void loader_notify(final int cur, final int max, final String name) { + long now = System.currentTimeMillis(); + + if (now - loader_notify_time < 100) + return; + + loader_notify_time = now; + SwingUtilities.invokeLater(new Runnable() { public void run() { pbar.setValue(cur); |