1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,99 @@ 1.4 +/* 1.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// Forward declarations of classes defined here. 1.29 +class GCTaskThread; 1.30 +class GCTaskTimeStamp; 1.31 + 1.32 +// Declarations of classes referenced in this file via pointer. 1.33 +class GCTaskManager; 1.34 + 1.35 +class GCTaskThread : public WorkerThread { 1.36 +private: 1.37 + // Instance state. 1.38 + GCTaskManager* _manager; // Manager for worker. 1.39 + const uint _processor_id; // Which processor the worker is on. 1.40 + 1.41 + GCTaskTimeStamp* _time_stamps; 1.42 + uint _time_stamp_index; 1.43 + 1.44 + GCTaskTimeStamp* time_stamp_at(uint index); 1.45 + 1.46 + public: 1.47 + // Factory create and destroy methods. 1.48 + static GCTaskThread* create(GCTaskManager* manager, 1.49 + uint which, 1.50 + uint processor_id) { 1.51 + return new GCTaskThread(manager, which, processor_id); 1.52 + } 1.53 + static void destroy(GCTaskThread* manager) { 1.54 + if (manager != NULL) { 1.55 + delete manager; 1.56 + } 1.57 + } 1.58 + // Methods from Thread. 1.59 + bool is_GC_task_thread() const { 1.60 + return true; 1.61 + } 1.62 + virtual void run(); 1.63 + // Methods. 1.64 + void start(); 1.65 + 1.66 + void print_task_time_stamps(); 1.67 + void print_on(outputStream* st) const; 1.68 + void print() const { print_on(tty); } 1.69 + 1.70 +protected: 1.71 + // Constructor. Clients use factory, but there could be subclasses. 1.72 + GCTaskThread(GCTaskManager* manager, uint which, uint processor_id); 1.73 + // Destructor: virtual destructor because of virtual methods. 1.74 + virtual ~GCTaskThread(); 1.75 + // Accessors. 1.76 + GCTaskManager* manager() const { 1.77 + return _manager; 1.78 + } 1.79 + uint which() const { 1.80 + return id(); 1.81 + } 1.82 + uint processor_id() const { 1.83 + return _processor_id; 1.84 + } 1.85 +}; 1.86 + 1.87 +class GCTaskTimeStamp : public CHeapObj 1.88 +{ 1.89 + private: 1.90 + jlong _entry_time; 1.91 + jlong _exit_time; 1.92 + char* _name; 1.93 + 1.94 + public: 1.95 + jlong entry_time() { return _entry_time; } 1.96 + jlong exit_time() { return _exit_time; } 1.97 + const char* name() const { return (const char*)_name; } 1.98 + 1.99 + void set_entry_time(jlong time) { _entry_time = time; } 1.100 + void set_exit_time(jlong time) { _exit_time = time; } 1.101 + void set_name(char* name) { _name = name; } 1.102 +};