ptrQueue.cpp revision 1111
2362N/A * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. 829N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 829N/A * This code is free software; you can redistribute it and/or modify it 829N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. 2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT 829N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 829N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 829N/A * version 2 for more details (a copy is included in the LICENSE file that 829N/A * accompanied this code). 829N/A * You should have received a copy of the GNU General Public License version 829N/A * 2 along with this work; if not, write to the Free Software Foundation, 829N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 829N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 829N/A * CA 95054 USA or visit www.sun.com if you need additional information or 829N/A#
include "incls/_precompiled.incl" 829N/A // We must NULL out the unused entries, then enqueue. // We must relock only because the caller will unlock, for the normal assert(
_sz > 0,
"Didn't set a buffer size.");
// Allocate space for the BufferNode in front of the buffer. assert(
_sz > 0,
"Didn't set a buffer size.");
assert(
_fl_owner ==
this,
"Free list reduction is allowed only for the owner");
// For now we'll adopt the strategy of deleting half. // This thread records the full buffer and allocates a new one (while // holding the lock if there is one). // Recycle the buffer. No allocation. // We don't lock. It is fine to be epsilon-precise here. // True here means that the buffer hasn't been deallocated and the caller may reuse it. // The buffer will be enqueued. The caller will have to get a new one. "Completed buffer length is wrong.");
assert(
_sz == 0 &&
sz > 0,
"Should be called only once.");
// Merge lists of buffers. Notify the processing threads. // The source queue is emptied as a result. The queues // must share the monitor.