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

19
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 (9934L/55K).

static <A> A evalInQ(Q q, IF0<A> f) {
  ret evalInQ(q, if0ToF0(f));
}

static <A> A evalInQ(Q q, 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 12 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, wnsclhtenguj

No comments. add comment

Snippet ID: #1019896
Snippet name: evalInQ - run in a queue, wait, get return value
Eternal ID of this version: #1019896/8
Text MD5: d83d19a8e753300b48aa495940f44014
Transpilation MD5: 7c4b47bb34717f4638e382f253beca72
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-06 18:57:57
Source code size: 376 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 252 / 3390
Version history: 7 change(s)
Referenced in: [show references]