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

20
LINES

< > BotCompany Repo | #1020593 // runInQAndWait - run in a queue, wait until done. run immediately if called from within queue

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (3679L) is out of date.

svoid runInQAndWait(Q q, Runnable r) {
  if (r == null) ret;
  if (isInQ(q)) ret with callF(r);
  
  final new Flag done;
  final new Var<Throwable> error;
  
  q.add(r {
    try {
      callF(r);
    } catch e {
      error.set(e);
    } finally {
      done.raise();
    }
  });
  
  done.waitUntilUp();
  if (error.has()) throw rethrow(error!);
}

Author comment

Began life as a copy of #1019896

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020593
Snippet name: runInQAndWait - run in a queue, wait until done. run immediately if called from within queue
Eternal ID of this version: #1020593/7
Text MD5: 1f36c8322889dce226067807ef2d38ce
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-22 08:29:20
Source code size: 368 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 362 / 468
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1031596 - runInQ - if we arenot in queue thread, add runnable to queue. don't wait until done. if in queue thread, run immediately