/* * Copyright (c) 2015, 2018, 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. *
*/ #include"precompiled.hpp" #include"logging/logLevel.hpp" #include"logging/logOutputList.hpp" #include"memory/allocation.inline.hpp" #include"runtime/atomic.hpp" #include"runtime/orderAccess.hpp" #include"utilities/globalDefinitions.hpp"
jint LogOutputList::increase_readers() {
jint result = Atomic::add(&_active_readers, 1);
assert(_active_readers > 0, "Ensure we have consistent state"); return result;
}
jint LogOutputList::decrease_readers() {
jint result = Atomic::add(&_active_readers, -1);
assert(result >= 0, "Ensure we have consistent state"); return result;
}
void LogOutputList::wait_until_no_readers() const {
OrderAccess::storeload(); while (Atomic::load(&_active_readers) != 0) { // Busy wait
} // Prevent mutations to the output list to float above the active reader check. // Such a reordering would lead to readers loading faulty data.
OrderAccess::loadstore();
}
// Delete all nodes from the linked list
wait_until_no_readers(); while (cur != NULL) {
LogOutputNode* next = cur->_next; delete cur;
cur = next;
}
}
void LogOutputList::remove_output(LogOutputList::LogOutputNode* node) {
assert(node != NULL, "Node must be non-null");
// Remove node from _level_start first bool found = false; for (uint level = LogLevel::First; level < LogLevel::Count; level++) { if (_level_start[level] == node) {
found = true;
_level_start[level] = node->_next;
}
}
// Now remove it from the linked list for (LogOutputNode* cur = _level_start[LogLevel::Last]; cur != NULL; cur = cur->_next) { if (cur->_next == node) {
found = true;
cur->_next = node->_next; break;
}
}
assert(found, "Node to be removed should always be found");
// Set the next pointer to the first node of a lower level for (node->_next = _level_start[level];
node->_next != NULL && node->_next->_level == level;
node->_next = node->_next->_next) {
}
// Update the _level_start index for (int l = LogLevel::Last; l >= level; l--) { if (_level_start[l] == NULL || _level_start[l]->_level < level) {
_level_start[l] = node;
}
}
// Add the node the list for (LogOutputNode* cur = _level_start[LogLevel::Last]; cur != NULL; cur = cur->_next) { if (cur != node && cur->_next == node->_next) {
cur->_next = node; break;
}
}
}
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 ist noch experimentell.