src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp
changeset 54623 1126f0607c70
parent 50429 83aec1d357d4
child 54645 05aaccf7d558
equal deleted inserted replaced
54622:a8dcacf95bff 54623:1126f0607c70
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   108 }
   108 }
   109 
   109 
   110 void JfrPostBox::synchronous_post(int msg) {
   110 void JfrPostBox::synchronous_post(int msg) {
   111   assert(is_synchronous(msg), "invariant");
   111   assert(is_synchronous(msg), "invariant");
   112   assert(!JfrMsg_lock->owned_by_self(), "should not hold JfrMsg_lock here!");
   112   assert(!JfrMsg_lock->owned_by_self(), "should not hold JfrMsg_lock here!");
   113   MutexLockerEx msg_lock(JfrMsg_lock);
   113   MutexLocker msg_lock(JfrMsg_lock);
   114   deposit(msg);
   114   deposit(msg);
   115   // serial_id is used to check when what we send in has been processed.
   115   // serial_id is used to check when what we send in has been processed.
   116   // _msg_read_serial is read under JfrMsg_lock protection.
   116   // _msg_read_serial is read under JfrMsg_lock protection.
   117   const uintptr_t serial_id = OrderAccess::load_acquire(&_msg_read_serial) + 1;
   117   const uintptr_t serial_id = OrderAccess::load_acquire(&_msg_read_serial) + 1;
   118   JfrMsg_lock->notify_all();
   118   JfrMsg_lock->notify_all();
   166   JfrMsg_lock->notify();
   166   JfrMsg_lock->notify();
   167 }
   167 }
   168 
   168 
   169 // safeguard to ensure no threads are left waiting
   169 // safeguard to ensure no threads are left waiting
   170 void JfrPostBox::notify_collection_stop() {
   170 void JfrPostBox::notify_collection_stop() {
   171   MutexLockerEx msg_lock(JfrMsg_lock);
   171   MutexLocker msg_lock(JfrMsg_lock);
   172   JfrMsg_lock->notify_all();
   172   JfrMsg_lock->notify_all();
   173 }
   173 }