scope botAppendToMechList_combining. static SS #untransmitted = synchroMap(); static ReliableSingleThread #rst; static int #delay = 2000; svoid botAppendToMechList_combining(S name, S text) { if (emptyAfterTrim(text)) ret; synchronized(untransmitted) { S s = untransmitted.get(name); untransmitted.put(name, appendNewLineIfNempty(s) + text); if (rst == null) rst = rstWithDelay(#delay, r #upload); } rst.trigger(); } svoid #upload() { SS data = cloneAndClearMap(untransmitted); for (S name, text : data) { botAppendToMechList_now(name, text); } } svoid cleanMeUp_botAppendToMechList_combining { while (rst != null && rst.running()) sleep(10); } end scope
Began life as a copy of #1014094
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017613 |
Snippet name: | botAppendToMechList_combining - coalesces transfers to avoid spam marker (OK) |
Eternal ID of this version: | #1017613/5 |
Text MD5: | 053af0b12ad554c1e93ce67ec6e1f872 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-30 14:27:48 |
Source code size: | 726 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 342 / 377 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1030046 - ReliableSingleThread_Multi - handle coalescing updates for multiple objects (all executed in a single thread) |