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)

static L<CriticalAction> beginCriticalAction_inFlight = synchroList();

sclass CriticalAction is AutoCloseable {
  S description;
  
  *() {}
  *(S *description) {}
  
  public void done aka close() {
    beginCriticalAction_inFlight.remove(this);
  }
}

static CriticalAction beginCriticalAction(S description) {
  ping();
  CriticalAction c = new CriticalAction(description);
  beginCriticalAction_inFlight.add(c);
  ret c;
}

svoid cleanMeUp_beginCriticalAction() {
  int n = 0;
  while (nempty(beginCriticalAction_inFlight)) {
    int m = l(beginCriticalAction_inFlight);
    if (m != n) {
      n = m;
      pcall {
        print("Waiting for " + n2(n, "critical actions") + ": " + join(", ", collect(beginCriticalAction_inFlight, "description"));
      }
    }
    sleepInCleanUp(10);
  }
}

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: 578 / 628
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1007728 - criticalActionsInFlight