package pw.koj.jetstreem.core;

import java.util.concurrent.LinkedBlockingQueue;

public final class StrmQueue extends LinkedBlockingQueue<StrmQueueEntry> {
    private static StrmQueue instance;

    private StrmQueue() {
        super();
    }

    public static synchronized StrmQueue getInstance() {
        if (instance == null) {
            instance = new StrmQueue();
        }
        return instance;
    }

    public void queueExec() {
        StrmQueueEntry entry = this.poll();

        entry.perform();
    }

    public void push(Streem strm, StrmFunc func, Object data) {
        StrmQueueEntry entry = new StrmQueueEntry(strm, func, data);
        this.offer(entry);
    }

    public boolean queueP() {
        return this.size() > 0;
    }

}


@@ -708,14 +708,20 @@
 ean 
-queueP
+hasRemaining
 () %7B
@@ -760,11 +760,255 @@
 %0A    %7D%0A%0A
+    public void loop() %7B%0A        for(;;) %7B%0A            queueExec();%0A%0A            StrmIOLoop ioLoop = StrmIOLoop.getInstance();%0A            if (ioLoop.hasNoRegistrant() && !hasRemaining()) %7B%0A                break;%0A            %7D%0A        %7D%0A    %7D%0A%0A
 %7D%0A%0A

add loop() to StrmQueue