Skip to content

Commit c980638

Browse files
Vitalii ChulakYanVugenfirer
authored andcommitted
[viofs] Extract SCOPE_EXIT macro from utils.h
Signed-off-by: Vitalii Chulak <vitalii@daynix.com>
1 parent 000f24d commit c980638

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

viofs/svc/scope_exit.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
template <typename EF> class scope_exit
2+
{
3+
EF exit_func;
4+
5+
public:
6+
scope_exit(EF &&exit_func) : exit_func{exit_func} {};
7+
~scope_exit()
8+
{
9+
exit_func();
10+
}
11+
};
12+
13+
#define SCOPE_EXIT(x, action, ...) scope_exit x##_se([x, __VA_ARGS__] action);

viofs/svc/utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <functional>
3535
#include <memory>
3636
#include <string>
37+
#include "scope_exit.h"
3738

3839
template <typename EF>
3940
class scope_exit

viofs/svc/virtiofs.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@
272272
</ItemGroup>
273273
<ItemGroup>
274274
<ClInclude Include="fusereq.h" />
275+
<ClInclude Include="scope_exit.h" />
275276
<ClInclude Include="utils.h" />
276277
</ItemGroup>
277278
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
278279
<Import Project="$(MSBuildProjectDirectory)\..\..\build\Driver.Common.targets" />
279280
<ImportGroup Label="ExtensionTargets">
280281
</ImportGroup>
281-
</Project>
282+
</Project>

0 commit comments

Comments
 (0)