< prev index next >
src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp
Print this page
*** 85,95 ****
void JfrPostBox::deposit(int new_messages) {
while (true) {
const int current_msgs = Atomic::load(&_messages);
// OR the new message
const int exchange_value = current_msgs | new_messages;
! const int result = Atomic::cmpxchg(exchange_value, &_messages, current_msgs);
if (result == current_msgs) {
return;
}
/* Some other thread just set exactly what this thread wanted */
if ((result & new_messages) == new_messages) {
--- 85,95 ----
void JfrPostBox::deposit(int new_messages) {
while (true) {
const int current_msgs = Atomic::load(&_messages);
// OR the new message
const int exchange_value = current_msgs | new_messages;
! const int result = Atomic::cmpxchg(&_messages, current_msgs, exchange_value);
if (result == current_msgs) {
return;
}
/* Some other thread just set exactly what this thread wanted */
if ((result & new_messages) == new_messages) {
*** 137,147 ****
return Atomic::load(&_messages) == 0;
}
int JfrPostBox::collect() {
// get pending and reset to 0
! const int messages = Atomic::xchg(0, &_messages);
if (check_waiters(messages)) {
_has_waiters = true;
assert(JfrMsg_lock->owned_by_self(), "incrementing _msg_read_serial is protected by JfrMsg_lock");
// Update made visible on release of JfrMsg_lock via fence instruction in Monitor::IUnlock.
++_msg_read_serial;
--- 137,147 ----
return Atomic::load(&_messages) == 0;
}
int JfrPostBox::collect() {
// get pending and reset to 0
! const int messages = Atomic::xchg(&_messages, 0);
if (check_waiters(messages)) {
_has_waiters = true;
assert(JfrMsg_lock->owned_by_self(), "incrementing _msg_read_serial is protected by JfrMsg_lock");
// Update made visible on release of JfrMsg_lock via fence instruction in Monitor::IUnlock.
++_msg_read_serial;
< prev index next >