source: java/main/src/main/java/com/framsticks/util/PeriodicTask.java @ 85

Last change on this file since 85 was 85, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • upgrade to Java 7
    • use try-multi-catch clauses
    • use try-with-resources were appropriate
  • configure FindBugs? (use mvn site and then navigate in browser to the report)
    • remove most bugs found
  • parametrize Dispatching environment (Dispatcher, RunAt?) to enforce more control on the place of closures actual call

CHANGELOG:
Rework FavouritesXMLFactory.

FindBugs?. Thread start.

FindBugs?. Minor change.

FindBugs?. Iterate over entrySet.

FindBugs?. Various.

FindBug?.

FindBug?. Encoding.

FindBug?. Final fields.

FindBug?.

Remove synchronization bug in ClientConnection?.

Experiments with findbugs.

Finish parametrization.

Make RunAt? an abstract class.

More changes in parametrization.

More changes in parametrizing dispatching.

Several changes to parametrize tasks.

Rename Runnable to RunAt?.

Add specific framsticks Runnable.

Add JSR305 (annotations).

Add findbugs reporting.

More improvements to ParamBuilder? wording.

Make FramsClass? accept also ParamBuilder?.

Change wording of ParamBuilder?.

Change wording of Request creation.

Use Java 7 exception catch syntax.

Add ScopeEnd? class.

Upgrade to Java 7.

File size: 687 bytes
Line 
1package com.framsticks.util;
2
3import com.framsticks.util.dispatching.Dispatcher;
4import com.framsticks.util.dispatching.Task;
5import com.framsticks.util.dispatching.RunAt;
6
7/**
8 * @author Piotr Sniegowski
9 */
10public abstract class PeriodicTask<C> extends RunAt<C> {
11
12        protected final long period;
13        protected Dispatcher<? super C> dispatcher;
14
15        public PeriodicTask(Dispatcher<? super C> dispatcher, long period) {
16                this.period = period;
17                this.dispatcher = dispatcher;
18                dispatcher.invokeLater(this);
19        }
20
21
22        public void again() {
23                dispatcher.invokeLater(new Task<C>(System.currentTimeMillis() + period) {
24                        @Override
25                        public void run() {
26                                PeriodicTask.this.run();
27                        }
28                });
29        }
30
31}
Note: See TracBrowser for help on using the repository browser.