Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
scoped_exit.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <utility>
4
5
namespace
fc
{
6
7
template
<
typename
Callback>
8
class
scoped_exit
{
9
public
:
10
template
<
typename
C>
11
scoped_exit
( C&& c ):callback(
std
::forward<C>(c) ){}
12
13
scoped_exit
(
scoped_exit
&& mv )
14
:callback(
std
::move( mv.callback ) ),canceled(mv.canceled)
15
{
16
mv.canceled =
true
;
17
}
18
19
scoped_exit
(
const
scoped_exit
& ) =
delete
;
20
scoped_exit
&
operator=
(
const
scoped_exit
& ) =
delete
;
21
22
~scoped_exit
() {
23
if
(!canceled)
24
try
{ callback(); }
catch
( ... ) {}
25
}
26
27
void
cancel
() { canceled =
true
; }
28
29
private
:
30
Callback callback;
31
bool
canceled =
false
;
32
};
33
34
template
<
typename
Callback>
35
scoped_exit<Callback>
make_scoped_exit
( Callback&& c ) {
36
return
scoped_exit<Callback>
( std::forward<Callback>(c) );
37
}
38
39
}
fc::scoped_exit
Definition
scoped_exit.hpp:8
fc::scoped_exit::operator=
scoped_exit & operator=(const scoped_exit &)=delete
fc::scoped_exit::~scoped_exit
~scoped_exit()
Definition
scoped_exit.hpp:22
fc::scoped_exit::scoped_exit
scoped_exit(const scoped_exit &)=delete
fc::scoped_exit::scoped_exit
scoped_exit(C &&c)
Definition
scoped_exit.hpp:11
fc::scoped_exit::scoped_exit
scoped_exit(scoped_exit &&mv)
Definition
scoped_exit.hpp:13
fc::scoped_exit::cancel
void cancel()
Definition
scoped_exit.hpp:27
fc
namespace sysio::chain
Definition
authority.cpp:3
fc::make_scoped_exit
scoped_exit< Callback > make_scoped_exit(Callback &&c)
Definition
scoped_exit.hpp:35
std
Definition
name.hpp:106
libraries
fc
include
fc
scoped_exit.hpp
Generated by
1.12.0