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).

1  
static <A> A evalInQ(Q q, IF0<A> f) {
2  
  ret evalInQ(q, if0ToF0(f));
3  
}
4  
5  
static <A> A evalInQ(Q q, F0<A> f) {
6  
  if (isInQ(q)) ret callF(f);
7  
  
8  
  final new Var<Either<A, Throwable>> var;
9  
  
10  
  q.add(r {
11  
    try {
12  
      var.set(eitherA(callF(f)));
13  
    } catch e {
14  
      var.set(eitherB(e));
15  
    }
16  
  });
17  
  
18  
  ret returnOrThrow_either(waitForVarToBeNotNull(var));
19  
}

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: 251 / 3390
Version history: 7 change(s)
Referenced in: [show references]