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

12
LINES

< > BotCompany Repo | #1006169 // waitUntilVarSet

JavaX fragment (include)

1  
static <A> A waitUntilVarSet(Var<A> v) ctex {
2  
  synchronized(v) { while (!v.has()) v.wait(); ret v.get(); }
3  
}
4  
5  
static <A> A waitUntilVarSet(Var<A> v, int timeout) ctex {
6  
  synchronized(v) {
7  
    long time = nanoTime();
8  
    while (!v.has() && (nanoTime()-time) < timeout*900000)
9  
      v.wait(timeout); // XXX-???
10  
    ret v.get();
11  
  }
12  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006169
Snippet name: waitUntilVarSet
Eternal ID of this version: #1006169/3
Text MD5: a4b7b9e3bc36672ca5f48f45531f487b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-23 14:30:32
Source code size: 344 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 590 / 555
Version history: 2 change(s)
Referenced in: [show references]