From ae2c6b26c2453cfb84153c39861a1bcd02479a85 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 4 Nov 2021 14:48:07 +0800 Subject: -textureUnitBucket --- Runtime/Utilities/AutoInvoke.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Runtime/Utilities/AutoInvoke.h (limited to 'Runtime/Utilities/AutoInvoke.h') 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); + -- cgit v1.1-26-g67d0