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

25
LINES

< > BotCompany Repo | #1001574 // iterateOverBlockingQueue

JavaX fragment (include)

static <A> Iterable<A> iterateOverBlockingQueue(final LinkedBlockingQueue<A> q) {
  return new Iterable<A>() {
    public Iterator<A> iterator() {
      return new Iterator<A>() {
        A x;
        
        public boolean hasNext() ctex {
          while (x == null)
            x = q.poll(1, TimeUnit.DAYS);
          return true;
        }
        
        public A next() {
          hasNext();
          A _x = x;
          x = null;
          return _x;
        }
        
        public void remove() {
        }
      };
    }
  };
}

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