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 und die Messung sind noch experimentell.