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)

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

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: 43 / 65
Referenced in: [show references]

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