diff options
author | chai <chaifix@163.com> | 2021-11-04 14:48:07 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-04 14:48:07 +0800 |
commit | ae2c6b26c2453cfb84153c39861a1bcd02479a85 (patch) | |
tree | 259457dcd09db3c256ff613c4483e67495d29fec /Runtime/Utilities | |
parent | d7c051cecf0db9056e94d5e80146aa0b066e606b (diff) |
-textureUnitBucket
Diffstat (limited to 'Runtime/Utilities')
-rw-r--r-- | Runtime/Utilities/AutoInvoke.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Runtime/Utilities/AutoInvoke.h b/Runtime/Utilities/AutoInvoke.h new file mode 100644 index 0000000..a443960 --- /dev/null +++ b/Runtime/Utilities/AutoInvoke.h @@ -0,0 +1,27 @@ +#pragma once
+
+typedef void(*AutoInvokeAction)();
+
+// RAII auto call
+class AutoInvokerWhenLeave
+{
+public:
+ AutoInvokerWhenLeave(AutoInvokeAction func)
+ {
+ m_Func = func;
+ };
+ ~AutoInvokerWhenLeave()
+ {
+ if (m_Func)
+ {
+ m_Func();
+ }
+ }
+private:
+ AutoInvokeAction m_Func;
+
+};
+
+#define InvokeWhenLeave(func) \
+AutoInvokerWhenLeave auto_invoker = AutoInvokerWhenLeave(func);
+
|