Adds remaining setup logic to implement destroy in Device and ObjectBase.

- Renames some of the Device functions to be consistent with documentation
- Reverts change in https://dawn-review.googlesource.com/c/dawn/+/64820 for overloading mDevice == nullptr to determine if objects are alive because device is needed for error propagation. Instead, use list existence to determine if objects are alive
- Updates destroy api to return bool upwards in case we need to further process the extending objects
- Adds tracking functions in ObjectBase
- Adds final tag to all backend Device implementations
- Adds MoveInto LinkedList support to move list elements in O(1)

Bug: dawn:628
Change-Id: Iff70f4f7d55f46ee52d1bd0e02e3671819f2eed4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65861
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Loko Kung
2021-10-12 17:46:26 +00:00
committed by Dawn LUCI CQ
parent e355bb8e65
commit fc5a7d414f
17 changed files with 174 additions and 44 deletions

View File

@@ -6,6 +6,7 @@
// modifications:
// - Added iterators for ranged based iterations
// - Added in list check before removing node to prevent segfault, now returns true iff removed
// - Added MoveInto functionality for moving list elements to another list
#ifndef COMMON_LINKED_LIST_H
#define COMMON_LINKED_LIST_H
@@ -89,6 +90,12 @@
// needs to glue on the "next" and "previous" pointers using
// some internal node type.
// Forward declarations of the types in order for recursive referencing and friending.
template <typename T>
class LinkNode;
template <typename T>
class LinkedList;
template <typename T>
class LinkNode {
public:
@@ -165,6 +172,7 @@ class LinkNode {
}
private:
friend class LinkedList<T>;
LinkNode<T>* previous_;
LinkNode<T>* next_;
};
@@ -190,6 +198,20 @@ class LinkedList {
e->InsertBefore(&root_);
}
// Moves all elements (in order) of the list and appends them into |l| leaving the list empty.
void MoveInto(LinkedList<T>* l) {
if (empty()) {
return;
}
l->root_.previous_->next_ = root_.next_;
root_.next_->previous_ = l->root_.previous_;
l->root_.previous_ = root_.previous_;
root_.previous_->next_ = &l->root_;
root_.next_ = &root_;
root_.previous_ = &root_;
}
LinkNode<T>* head() const {
return root_.next();
}