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

25
LINES

< > BotCompany Repo | #1001574 // iterateOverBlockingQueue

JavaX fragment (include)

1  
static <A> Iterable<A> iterateOverBlockingQueue(final LinkedBlockingQueue<A> q) {
2  
  return new Iterable<A>() {
3  
    public Iterator<A> iterator() {
4  
      return new Iterator<A>() {
5  
        A x;
6  
        
7  
        public boolean hasNext() ctex {
8  
          while (x == null)
9  
            x = q.poll(1, TimeUnit.DAYS);
10  
          return true;
11  
        }
12  
        
13  
        public A next() {
14  
          hasNext();
15  
          A _x = x;
16  
          x = null;
17  
          return _x;
18  
        }
19  
        
20  
        public void remove() {
21  
        }
22  
      };
23  
    }
24  
  };
25  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001574
Snippet name: iterateOverBlockingQueue
Eternal ID of this version: #1001574/1
Text MD5: 414bb7d927dc88554770ae231da083ab
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-25 14:57:17
Source code size: 567 bytes / 25 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 608 / 823
Referenced in: [show references]