Use smart Refs for IOKit and CoreFoundation objects.
Bug: dawn:89
Change-Id: Idea634bcc65ab4ec017f4e4c2431e95915f533df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32661
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
diff --git a/src/common/RefBase.h b/src/common/RefBase.h
index 508b424..a1db6a9 100644
--- a/src/common/RefBase.h
+++ b/src/common/RefBase.h
@@ -15,6 +15,7 @@
#ifndef COMMON_REFBASE_H_
#define COMMON_REFBASE_H_
+#include "common/Assert.h"
#include "common/Compiler.h"
#include <type_traits>
@@ -163,6 +164,11 @@
mValue = value;
}
+ T* InitializeInto() DAWN_NO_DISCARD {
+ ASSERT(mValue == kNullValue);
+ return &mValue;
+ }
+
private:
// Friend is needed so that instances of RefBase<U> can call Reference and Release on
// RefBase<T>.