duke@435: /* mikael@4153: * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKTHREAD_HPP stefank@2314: #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKTHREAD_HPP stefank@2314: stefank@2314: #include "runtime/thread.hpp" stefank@2314: duke@435: // Forward declarations of classes defined here. duke@435: class GCTaskThread; duke@435: class GCTaskTimeStamp; duke@435: duke@435: // Declarations of classes referenced in this file via pointer. duke@435: class GCTaskManager; duke@435: duke@435: class GCTaskThread : public WorkerThread { jmasa@3294: friend class GCTaskManager; duke@435: private: duke@435: // Instance state. duke@435: GCTaskManager* _manager; // Manager for worker. duke@435: const uint _processor_id; // Which processor the worker is on. duke@435: duke@435: GCTaskTimeStamp* _time_stamps; duke@435: uint _time_stamp_index; duke@435: duke@435: GCTaskTimeStamp* time_stamp_at(uint index); duke@435: jmasa@3294: bool _is_working; // True if participating in GC tasks jmasa@3294: duke@435: public: duke@435: // Factory create and destroy methods. duke@435: static GCTaskThread* create(GCTaskManager* manager, duke@435: uint which, duke@435: uint processor_id) { duke@435: return new GCTaskThread(manager, which, processor_id); duke@435: } duke@435: static void destroy(GCTaskThread* manager) { duke@435: if (manager != NULL) { duke@435: delete manager; duke@435: } duke@435: } duke@435: // Methods from Thread. duke@435: bool is_GC_task_thread() const { duke@435: return true; duke@435: } duke@435: virtual void run(); duke@435: // Methods. duke@435: void start(); duke@435: duke@435: void print_task_time_stamps(); duke@435: void print_on(outputStream* st) const; duke@435: void print() const { print_on(tty); } duke@435: duke@435: protected: duke@435: // Constructor. Clients use factory, but there could be subclasses. duke@435: GCTaskThread(GCTaskManager* manager, uint which, uint processor_id); duke@435: // Destructor: virtual destructor because of virtual methods. duke@435: virtual ~GCTaskThread(); duke@435: // Accessors. duke@435: GCTaskManager* manager() const { duke@435: return _manager; duke@435: } duke@435: uint which() const { duke@435: return id(); duke@435: } duke@435: uint processor_id() const { duke@435: return _processor_id; duke@435: } jmasa@3294: void set_is_working(bool v) { _is_working = v; } duke@435: }; duke@435: zgu@3900: class GCTaskTimeStamp : public CHeapObj duke@435: { duke@435: private: duke@435: jlong _entry_time; duke@435: jlong _exit_time; duke@435: char* _name; duke@435: duke@435: public: duke@435: jlong entry_time() { return _entry_time; } duke@435: jlong exit_time() { return _exit_time; } duke@435: const char* name() const { return (const char*)_name; } duke@435: duke@435: void set_entry_time(jlong time) { _entry_time = time; } duke@435: void set_exit_time(jlong time) { _exit_time = time; } duke@435: void set_name(char* name) { _name = name; } duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKTHREAD_HPP