ptrQueue.hpp revision 1317
579N/A * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. 342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 342N/A * This code is free software; you can redistribute it and/or modify it 342N/A * under the terms of the GNU General Public License version 2 only, as 342N/A * published by the Free Software Foundation. 342N/A * This code is distributed in the hope that it will be useful, but WITHOUT 342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 342N/A * version 2 for more details (a copy is included in the LICENSE file that 342N/A * accompanied this code). 342N/A * You should have received a copy of the GNU General Public License version 342N/A * 2 along with this work; if not, write to the Free Software Foundation, 342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 342N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 342N/A * CA 95054 USA or visit www.sun.com if you need additional information or 342N/A// There are various techniques that require threads to be able to log 342N/A// addresses. For example, a generational write barrier might log 342N/A// the addresses of modified old-generation objects. This type supports 1111N/A// The definition of placement operator new(size_t, void*) in the <new>. 342N/A // The ptr queue set to which this queue belongs. 342N/A // Whether updates should be logged. 342N/A // The index at which an object was last enqueued. Starts at "_sz" 342N/A // (indicating an empty buffer) and goes towards zero. 342N/A // The size of the buffer. 342N/A // If true, the queue is permanent, and doesn't need to deallocate 342N/A // its buffer in the destructor (since that obtains a lock which may not 342N/A // be legally locked by then. 342N/A // If there is a lock associated with this buffer, this is that lock. 342N/A // Initialize this queue to contain a null buffer, and be part of the 342N/A // Release any contained resources. 441N/A // Calls flush() when destroyed. 342N/A // Associate a lock with a ptr queue. 342N/A // Enqueues the given "obj". 342N/A // Set the "active" property of the queue to "b". An enqueue to an 342N/A // inactive thread is a no-op. Setting a queue to inactive resets its 342N/A // log to the empty state. 342N/A // To support compiler. 1111N/A // Align the size of the structure to the size of the pointer 1111N/A // BufferNode is allocated before the buffer. 1111N/A // The chunk of memory that holds both of them is a block. 1111N/A // Produce a new BufferNode given a buffer. 1111N/A // The following are the required conversion routines: 342N/A// A PtrQueueSet represents resources common to a set of pointer queues. 342N/A// In particular, the individual queues allocate buffers from this shared 342N/A// set, and return completed buffers to the set. 342N/A// All these variables are are protected by the TLOQ_CBL_mon. XXX ??? 342N/A // This (and the interpretation of the first element as a "next" 342N/A // pointer) are protected by the TLOQ_FL_lock. 616N/A // Queue set can share a freelist. The _fl_owner variable 616N/A // specifies the owner. It is set to "this" by default. 342N/A // The size of all buffers in the set. 342N/A // If true, notify_all on _cbl_mon when the threshold is reached. 342N/A // Maximum number of elements allowed on completed queue: after that, 342N/A // enqueuer does the work itself. Zero indicates no maximum. 342N/A // A mutator thread does the the work of processing a buffer. 342N/A // Returns "true" iff the work is complete (and the buffer may be 342N/A // Create an empty ptr queue set. 342N/A // Because of init-order concerns, we can't pass these as constructor 342N/A // Return an empty oop array of size _sz (required to be non-zero). 342N/A // Return an empty buffer to the free list. The "buf" argument is 342N/A // required to be a pointer to the head of an array of length "_sz". 342N/A // Declares that "buf" is a complete buffer. 1111N/A // To be invoked by the mutator. 342N/A // Set the buffer size. Should be called before any "enqueue" operation 342N/A // can be called. And should only be called once. 342N/A // Get the buffer size. 1111N/A // Get/Set the number of completed buffers that triggers log processing. 342N/A // Must only be called at a safe point. Indicates that the buffer free 342N/A // list size may be reduced, if that is deemed desirable. 1111N/A // Notify the consumer if the number of buffers crossed the threshold