fixing put pixel, adding scene change checker

This commit is contained in:
2024-10-21 01:48:01 +02:00
parent 4f755f8a6f
commit 0304834008
28 changed files with 302 additions and 201 deletions

33
runtime/Includes/Utils/CallOnExit.h git.filemode.normal_file
View File

@@ -0,0 +1,33 @@
#ifndef __MLX_CALL_ON_EXIT__
#define __MLX_CALL_ON_EXIT__
namespace mlx
{
template <typename F>
class CallOnExit
{
public:
CallOnExit() = default;
CallOnExit(F&& functor);
CallOnExit(const CallOnExit&) = delete;
CallOnExit(CallOnExit&&) = delete;
void CallAndReset();
void Reset();
CallOnExit& operator=(const CallOnExit&) = delete;
CallOnExit& operator=(CallOnExit&&) = default;
~CallOnExit();
private:
std::optional<F> m_functor;
};
template<typename F>
CallOnExit(F) -> CallOnExit<F>;
}
#include <Utils/CallOnExit.inl>
#endif

29
runtime/Includes/Utils/CallOnExit.inl git.filemode.normal_file
View File

@@ -0,0 +1,29 @@
#pragma once
#include <Utils/CallOnExit.h>
namespace mlx
{
template<typename F>
CallOnExit<F>::CallOnExit(F&& functor) : m_functor(std::move(functor)) {}
template<typename F>
CallOnExit<F>::~CallOnExit()
{
if(m_functor.has_value())
(*m_functor)();
}
template<typename F>
void CallOnExit<F>::CallAndReset()
{
if(m_functor.has_value())
(*m_functor)();
m_functor.reset();
}
template<typename F>
void CallOnExit<F>::Reset()
{
m_functor.reset();
}
}