< prev index next >
src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/Pool.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 28,39 ****
import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import java.util.concurrent.ConcurrentLinkedQueue;
! import java.lang.ref.WeakReference;
/**
* General-purpose object pool.
*
* <p>
--- 28,41 ----
import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
+
import java.util.concurrent.ConcurrentLinkedQueue;
! import java.lang.ref.SoftReference;
!
/**
* General-purpose object pool.
*
* <p>
*** 48,58 ****
* @author Kohsuke Kawaguchi
*/
public abstract class Pool<T> {
// volatile since multiple threads may access queue reference
! private volatile WeakReference<ConcurrentLinkedQueue<T>> queue;
/**
* Gets a new object from the pool.
*
* <p>
--- 50,60 ----
* @author Kohsuke Kawaguchi
*/
public abstract class Pool<T> {
// volatile since multiple threads may access queue reference
! private volatile SoftReference<ConcurrentLinkedQueue<T>> queue;
/**
* Gets a new object from the pool.
*
* <p>
*** 67,86 ****
return create();
return t;
}
private ConcurrentLinkedQueue<T> getQueue() {
! WeakReference<ConcurrentLinkedQueue<T>> q = queue;
if (q != null) {
ConcurrentLinkedQueue<T> d = q.get();
if (d != null)
return d;
}
// overwrite the queue
ConcurrentLinkedQueue<T> d = new ConcurrentLinkedQueue<T>();
! queue = new WeakReference<ConcurrentLinkedQueue<T>>(d);
return d;
}
/**
--- 69,88 ----
return create();
return t;
}
private ConcurrentLinkedQueue<T> getQueue() {
! SoftReference<ConcurrentLinkedQueue<T>> q = queue;
if (q != null) {
ConcurrentLinkedQueue<T> d = q.get();
if (d != null)
return d;
}
// overwrite the queue
ConcurrentLinkedQueue<T> d = new ConcurrentLinkedQueue<T>();
! queue = new SoftReference<ConcurrentLinkedQueue<T>>(d);
return d;
}
/**
< prev index next >