Libraryless. Click here for Pure Java version (4083L/24K).
sclass ReliableSingleThread_Multi<A> { IVF1<A> processObject; int delay; // delay before changes are processed *(IVF1<A> *processObject) {} *(int *delay, IVF1<A> *processObject) {} *(int *delay, IVF1<A> *processObject, F0<AutoCloseable> enter) { setEnter(enter); } // internal Set<A> changedObjects = synchroSet(); ReliableSingleThread rst = new(r process); // notify of change in object void add(A a) { if (changedObjects.add(a)) rst.trigger(); } void addAll(Iterable<A> l) { fOr ping (A a : l) add(a); } private void process { sleep(delay); for ping (A object : syncCloneAndClearList(changedObjects)) pcallF(processObject, object); } void setEnter(F0<AutoCloseable> enter) { rst.enter = enter; } }
Began life as a copy of #1017613
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030046 |
Snippet name: | ReliableSingleThread_Multi - handle coalescing updates for multiple objects (all executed in a single thread) |
Eternal ID of this version: | #1030046/16 |
Text MD5: | 46746722114eaa9c82df593a2f6984f8 |
Transpilation MD5: | af976b88e3ea8d2bdb956cac7882ef90 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-29 02:47:02 |
Source code size: | 812 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 365 / 664 |
Version history: | 15 change(s) |
Referenced in: | [show references] |