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

33
LINES

< > BotCompany Repo | #1007239 // beginCriticalAction - critical actions delay the class's clean-up

JavaX fragment (include)

1  
static L<CriticalAction> beginCriticalAction_inFlight = synchroList();
2  
3  
sclass CriticalAction is AutoCloseable {
4  
  S description;
5  
  
6  
  *() {}
7  
  *(S *description) {}
8  
  
9  
  public void done aka close() {
10  
    beginCriticalAction_inFlight.remove(this);
11  
  }
12  
}
13  
14  
static CriticalAction beginCriticalAction(S description) {
15  
  ping();
16  
  CriticalAction c = new CriticalAction(description);
17  
  beginCriticalAction_inFlight.add(c);
18  
  ret c;
19  
}
20  
21  
svoid cleanMeUp_beginCriticalAction() {
22  
  int n = 0;
23  
  while (nempty(beginCriticalAction_inFlight)) {
24  
    int m = l(beginCriticalAction_inFlight);
25  
    if (m != n) {
26  
      n = m;
27  
      pcall {
28  
        print("Waiting for " + n2(n, "critical actions") + ": " + join(", ", collect(beginCriticalAction_inFlight, "description"));
29  
      }
30  
    }
31  
    sleepInCleanUp(10);
32  
  }
33  
}

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: #1007239
Snippet name: beginCriticalAction - critical actions delay the class's clean-up
Eternal ID of this version: #1007239/9
Text MD5: 79ff85f3e81a3590977746859329d1e1
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-06 02:08:42
Source code size: 828 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 579 / 630
Version history: 8 change(s)
Referenced in: [show references]