Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1017613 // botAppendToMechList_combining - coalesces transfers to avoid spam marker (OK)

JavaX fragment (include)

1  
scope botAppendToMechList_combining.
2  
3  
static SS #untransmitted = synchroMap();
4  
static ReliableSingleThread #rst;
5  
static int #delay = 2000;
6  
7  
svoid botAppendToMechList_combining(S name, S text) {
8  
  if (emptyAfterTrim(text)) ret;
9  
  
10  
  synchronized(untransmitted) {
11  
    S s = untransmitted.get(name);
12  
    untransmitted.put(name, appendNewLineIfNempty(s) + text);
13  
    if (rst == null) rst = rstWithDelay(#delay, r #upload);
14  
  }
15  
  
16  
  rst.trigger();
17  
}
18  
19  
svoid #upload() {
20  
  SS data = cloneAndClearMap(untransmitted);
21  
  for (S name, text : data) {
22  
    botAppendToMechList_now(name, text);
23  
  }
24  
}
25  
26  
svoid cleanMeUp_botAppendToMechList_combining {
27  
  while (rst != null && rst.running()) sleep(10);
28  
}
29  
30  
end scope

Author comment

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: 270 / 309
Version history: 4 change(s)
Referenced in: [show references]