mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-12-06 07:12:28 +01:00
28 lines
464 B
C++
28 lines
464 B
C++
#pragma once
|
|
|
|
// Generic deferred routine wrapper
|
|
// Use-case is similar to "defer" statement in other languages, just invokes a callback when the object goes out of scope
|
|
|
|
#include <functional>
|
|
|
|
namespace utils
|
|
{
|
|
template <typename F>
|
|
requires std::is_invocable_v<F>
|
|
class deferred_op
|
|
{
|
|
public:
|
|
deferred_op(F&& callback)
|
|
: m_callback(callback)
|
|
{}
|
|
|
|
~deferred_op()
|
|
{
|
|
m_callback();
|
|
}
|
|
|
|
private:
|
|
F m_callback;
|
|
};
|
|
}
|