mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-18 04:45:12 +00:00
Merge branch 'master' into windows-clang
This commit is contained in:
commit
b66d94b398
88 changed files with 1972 additions and 798 deletions
27
Utilities/deferred_op.hpp
Normal file
27
Utilities/deferred_op.hpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue