private void enqueue(Option<T> optionalElement)
{
try
{
while (!timedOffer(optionalElement))
{
procrastinate();
}
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private boolean timedOffer(Option<T> optionalElement) throws InterruptedException
{
WeakReference<BlockingQueue<Option<T>>> weak = queues.get();
BlockingQueue<Option<T>> queue = weak.get();
return queue == null || queue.offer(optionalElement, 1, TimeUnit.MINUTES);