mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8249560: Shenandoah: Fix racy GC request handling
Reviewed-by: shade
This commit is contained in:
parent
3770be7f70
commit
9694ca9eaf
1 changed files with 4 additions and 2 deletions
|
@ -511,13 +511,15 @@ void ShenandoahControlThread::handle_requested_gc(GCCause::Cause cause) {
|
||||||
// comes very late in the already running cycle, it would miss lots of new
|
// comes very late in the already running cycle, it would miss lots of new
|
||||||
// opportunities for cleanup that were made available before the caller
|
// opportunities for cleanup that were made available before the caller
|
||||||
// requested the GC.
|
// requested the GC.
|
||||||
size_t required_gc_id = get_gc_id() + 1;
|
|
||||||
|
|
||||||
MonitorLocker ml(&_gc_waiters_lock);
|
MonitorLocker ml(&_gc_waiters_lock);
|
||||||
while (get_gc_id() < required_gc_id) {
|
size_t current_gc_id = get_gc_id();
|
||||||
|
size_t required_gc_id = current_gc_id + 1;
|
||||||
|
while (current_gc_id < required_gc_id) {
|
||||||
_gc_requested.set();
|
_gc_requested.set();
|
||||||
_requested_gc_cause = cause;
|
_requested_gc_cause = cause;
|
||||||
ml.wait();
|
ml.wait();
|
||||||
|
current_gc_id = get_gc_id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue