diff options
author | Susan Franklin | 2007-10-22 17:37:46 +0000 |
---|---|---|
committer | Susan Franklin | 2007-10-22 17:37:46 +0000 |
commit | cffbfc1ec11be8776087425b3d5f2058c3c6026f (patch) | |
tree | 4d6d326a453c5bdb030d9b2abcb0c058f3637e4d /bundles/org.eclipse.equinox.p2.updatechecker | |
parent | 1ca4290368b9ba5430b75a02d5b7b69f20a5b431 (diff) | |
download | rt.equinox.p2-cffbfc1ec11be8776087425b3d5f2058c3c6026f.tar.gz rt.equinox.p2-cffbfc1ec11be8776087425b3d5f2058c3c6026f.tar.xz rt.equinox.p2-cffbfc1ec11be8776087425b3d5f2058c3c6026f.zip |
added initial delay arg
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.updatechecker')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java index 1e182db13..81a6da358 100644 --- a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java +++ b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java @@ -40,21 +40,23 @@ public class UpdateChecker { private class UpdateCheckThread extends Thread { boolean done = false; - long poll; + long poll, delay; IUpdateListener listener; Profile profile; - UpdateCheckThread(String profileId, long poll, IUpdateListener listener) { + UpdateCheckThread(String profileId, long delay, long poll, IUpdateListener listener) { this.poll = poll; + this.delay = delay; this.profile = profileRegistry.getProfile(profileId); } public void run() { - while (!done) { - try { - if (poll != ONE_TIME_CHECK) { - Thread.sleep(poll); - } + try { + if (delay != ONE_TIME_CHECK && delay > 0) { + Thread.sleep(delay); + } + while (!done) { + log("Checking for updates for " + profile.getProfileId() + " at " + getTimeStamp()); //$NON-NLS-1$ //$NON-NLS-2$ IInstallableUnit[] iusWithUpdates = checkForUpdates(profile); if (iusWithUpdates.length > 0) { @@ -65,14 +67,16 @@ public class UpdateChecker { } else { log("No updates were available"); //$NON-NLS-1$ } - if (poll == ONE_TIME_CHECK) { + if (delay == ONE_TIME_CHECK || delay <= 0) { done = true; + } else { + Thread.sleep(poll); } - } catch (InterruptedException e) { - // nothing - } catch (Exception e) { - log("Exception in update check thread", e); //$NON-NLS-1$ } + } catch (InterruptedException e) { + // nothing + } catch (Exception e) { + log("Exception in update check thread", e); //$NON-NLS-1$ } } } @@ -85,9 +89,9 @@ public class UpdateChecker { } } - public void addUpdateCheck(String profileId, long poll, IUpdateListener listener) { - log("Adding update checker for " + profileId); //$NON-NLS-1$ - UpdateCheckThread thread = new UpdateCheckThread(profileId, poll, listener); + public void addUpdateCheck(String profileId, long delay, long poll, IUpdateListener listener) { + log("Adding update checker for " + profileId + " at " + getTimeStamp()); //$NON-NLS-1$ //$NON-NLS-2$ + UpdateCheckThread thread = new UpdateCheckThread(profileId, delay, poll, listener); checkers.add(thread); thread.run(); } |