/* * Copyright (c) 2015, 2021, 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. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
class G1ServiceTask : public CHeapObj<mtGC> { friendclass G1ServiceTaskQueue; friendclass G1ServiceThread;
// The next absolute time this task should be executed.
jlong _time; // Name of the task. constchar* _name; // Next task in the task queue.
G1ServiceTask* _next; // The service thread this task is registered with.
G1ServiceThread* _service_thread;
// Do the actual work for the task. To get added back to the // execution queue a task can call schedule(delay_ms). virtualvoid execute() = 0;
protected: // Schedule the task on the associated service thread using // the provided delay in milliseconds. Can only be used when // currently running on the service thread. void schedule(jlong delay_ms);
// These setters are protected for use by testing and the // sentinel task only. void set_time(jlong time); void set_next(G1ServiceTask* next);
};
class G1SentinelTask : public G1ServiceTask { public:
G1SentinelTask(); virtualvoid execute();
};
class G1ServiceTaskQueue { // The sentinel task is the entry point of this priority queue holding the // service tasks. The queue is ordered by the time the tasks are scheduled // to run. To simplify list management the sentinel task has its time set // to max_jlong, guaranteeing it to be the last task in the queue.
G1SentinelTask _sentinel;
// Verify that the queue is ordered. void verify_task_queue() NOT_DEBUG_RETURN; public:
G1ServiceTaskQueue();
// The G1ServiceThread is used to periodically do a number of different tasks: // - re-assess the validity of the prediction for the // remembered set lengths of the young generation. // - check if a periodic GC should be scheduled. class G1ServiceThread: public ConcurrentGCThread { friendclass G1ServiceTask; // The monitor is used to ensure thread safety for the task queue // and allow other threads to signal the service thread to wake up.
Monitor _monitor;
G1ServiceTaskQueue _task_queue;
void run_service(); void stop_service();
// Return the next ready task, waiting until a task is ready. // Instead returns nullptr if termination requested.
G1ServiceTask* wait_for_task();
void run_task(G1ServiceTask* task);
// Helper used by both schedule_task() and G1ServiceTask::schedule() // to schedule a registered task to run after the given delay. void schedule(G1ServiceTask* task, jlong delay, bool notify);
public:
G1ServiceThread();
// Register a task with the service thread. The task is guaranteed not to run // until at least `delay_ms` has passed. If no delay is specified or the // delay is 0, the task will run in the earliest time possible. void register_task(G1ServiceTask* task, jlong delay_ms = 0);
// Schedule an already-registered task to run in at least `delay_ms` time, // and notify the service thread. void schedule_task(G1ServiceTask* task, jlong delay_ms);
};
#endif// SHARE_GC_G1_G1SERVICETHREAD_HPP
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.