All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flash3388.flashlib.util.collections.BlockingQueueConsumer Maven / Gradle / Ivy

package com.flash3388.flashlib.util.collections;

import com.flash3388.flashlib.util.concurrent.Interrupts;

import java.util.concurrent.BlockingQueue;
import java.util.function.Consumer;

public class BlockingQueueConsumer implements Consumer {

    private final BlockingQueue mBlockingQueue;

    public BlockingQueueConsumer(BlockingQueue blockingQueue) {
        mBlockingQueue = blockingQueue;
    }

    @Override
    public void accept(T t) {
        try {
            mBlockingQueue.put(t);
        } catch (InterruptedException e) {
            Interrupts.preserveInterruptState();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy