Libraryless. Click here for Pure Java version (3729L/20K).
1 | sclass FixedRateTimer extends java.util.Timer implements AutoCloseable { |
2 | *() { this(false); } |
3 | *(bool daemon) { this(defaultTimerName(), daemon); } |
4 | *(S name) { this(name, false); } |
5 | *(S name, bool daemon) { |
6 | super(name, daemon); |
7 | _registerTimer(this); |
8 | } |
9 | |
10 | L<Entry> entries = synchroList(); |
11 | |
12 | srecord noeq Entry(TimerTask task, long firstTime, long period) {} |
13 | |
14 | // Note: not all methods overridden; only use these ones |
15 | |
16 | public void scheduleAtFixedRate(TimerTask task, long delay, long period) { |
17 | entries.add(new Entry(task, now()+delay, period)); |
18 | super.scheduleAtFixedRate(task, delay, period); |
19 | } |
20 | |
21 | public void cancel() { |
22 | entries.clear(); |
23 | super.cancel(); |
24 | } |
25 | |
26 | public int purge() { |
27 | entries.clear(); |
28 | ret super.purge(); |
29 | } |
30 | |
31 | FixedRateTimer changeRate(int newPeriod) { |
32 | O r = ((SmartTimerTask) first(entries).task).r; |
33 | cancel(); |
34 | ret doEvery(newPeriod, r); |
35 | } |
36 | |
37 | close { cancel(); } |
38 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1013151 |
Snippet name: | FixedRateTimer - java.util.Timer that remembers what it is doing |
Eternal ID of this version: | #1013151/12 |
Text MD5: | e7181b85f7e1b91c828e8f21a234d8ea |
Transpilation MD5: | f93beee3beb91e1cb932c537ab098e46 |
Author: | stefan |
Category: | javax / timers |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-01 22:53:44 |
Source code size: | 991 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 731 / 1530 |
Version history: | 11 change(s) |
Referenced in: | [show references] |