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

15
LINES

< > BotCompany Repo | #1019896 - evalInQ - run in a queue, wait, get return value

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

Libraryless. Click here for Pure Java version (3624L/23K).

static <A> A evalInQ(Q q, final F0<A> f) {
  if (isInQ(q)) ret callF(f);
  
  final new Var<Either<A, Throwable>> var;
  
  q.add(r {
    try {
      var.set(eitherA(callF(f)));
    } catch e {
      var.set(eitherB(e));
    }
  });
  
  ret returnOrThrow_either(waitForVarToBeNotNull(var));
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019896
Snippet name: evalInQ - run in a queue, wait, get return value
Eternal ID of this version: #1019896/7
Text MD5: 94af56d24c761c95943d58595e33d943
Transpilation MD5: e3dcbf2553db93de70250850513d8655
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-25 18:30:48
Source code size: 307 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 132 / 2949
Version history: 6 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1019896 & http://1019896.tinybrain.de