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

15
LINES

< > BotCompany Repo | #1025646 // evalInQ_first - run in a queue (add to front), wait, get return value

JavaX fragment (include)

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

Author comment

Began life as a copy of #1019896

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025646
Snippet name: evalInQ_first - run in a queue (add to front), wait, get return value
Eternal ID of this version: #1025646/1
Text MD5: 8caa6b71b34f6d519c4283f55c28c016
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-12 16:06:24
Source code size: 360 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 131 / 165
Referenced in: [show references]