Libraryless. Click here for Pure Java version (2178L/14K).
sclass WaitForStableValue<A> { long period; A value; long valueSince; *() {} *(long *period) {} *(double seconds) { period = toMS(seconds); } synchronized A set(A a) { if (neq(a, value)) { value = a; valueSince = sysNow(); } ret get(); } synchronized A get() { ret valueSince != 0 && sysNow() >= valueSince+period ? value : null; } // clears only if result != null synchronized A setAndClear(A _a) { A a = set(_a); if (a != null) clear(); ret a; } public bool has() { ret get() != null; } void clear() { set(null); } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1015867 |
Snippet name: | WaitForStableValue |
Eternal ID of this version: | #1015867/10 |
Text MD5: | 4a2f2833a3082543bb64d1c8470f5d83 |
Transpilation MD5: | 09ef5f028d4bc0ea2d298b033edc7915 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-01 19:06:50 |
Source code size: | 637 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 355 / 1013 |
Version history: | 9 change(s) |
Referenced in: | #1019579 - OnStableValue #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |