Libraryless. Click here for Pure Java version (8037L/45K).
// returns last value sclass PrintPolledValueUntilPredicateOrTimeout<A> { settable IF0<A> makeValue; settable IPred<A> pred; // if true, loop ends settable double timeout = 60.0; settable int interval = 100; settable S printPrefix = ""; *(S *printPrefix, IF0<A> *makeValue, IPred<A> *pred) {} void printValue(A a) { printWithMS(printPrefix, a); } A get() { Timeout timeOut = new(timeout); A a = makeValue!; printValue(a); if (pred != null && pred.get(a)) ret a; while (!timeOut!) { A b = makeValue!; if (!eq(a, b)) printValue(a = b); if (pred != null && pred.get(a)) break; else sleep(interval); } ret a; } run { get(); } }
Began life as a copy of #1024356
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035352 |
Snippet name: | PrintPolledValueUntilPredicateOrTimeout |
Eternal ID of this version: | #1035352/13 |
Text MD5: | ba6fa224b08a6ae126a14b87e745c22d |
Transpilation MD5: | 2e81a65c0e893a76cc869be3730f9cf9 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-01 20:14:20 |
Source code size: | 776 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 175 / 319 |
Version history: | 12 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |