RESTinio
Loading...
Searching...
No Matches
restinio
utils
at_scope_exit.hpp
Go to the documentation of this file.
1
/*
2
* SObjectizer-5, RESTinio
3
*/
4
5
/*!
6
* @file
7
* @brief A simple implementation of %at_scope_exit concept.
8
*
9
* @note
10
* This code is borrowed from SObjectizer project:
11
* https://github.com/stiffstream/sobjectizer
12
*
13
* @since
14
* v.0.6.4
15
*/
16
17
#
pragma
once
18
19
#
include
<
utility
>
20
21
namespace
restinio
{
22
23
namespace
utils
{
24
25
namespace
scope_exit_details
{
26
27
/*!
28
* \brief Helper class for scope exit implementation.
29
*/
30
template
<
typename
L >
31
class
at_exit_t
32
{
33
L
m_lambda
;
34
public
:
35
at_exit_t
( L && l ) :
m_lambda
{ std::forward<L>(l) } {}
36
at_exit_t
(
at_exit_t
&& o ) :
m_lambda
{ std::move(o
.
m_lambda
) } {}
37
~
at_exit_t
() {
m_lambda
(
)
; }
38
};
39
40
}
/* namespace scope_exit_details */
41
42
/*!
43
* \brief Helper function for creation action to be performed at scope exit.
44
*
45
* Usage example:
46
* \code
47
if( needs_wait )
48
{
49
m_threads_to_wakeup += 1;
50
auto decrement_threads = at_scope_exit( [&m_threads_to_wakeup] {
51
--m_threads_to_wakeup;
52
} );
53
m_sleep_cond.wait_for( some_time, some_predicate );
54
}
55
* \endcode
56
*
57
*/
58
template
<
typename
L >
59
scope_exit_details
::
at_exit_t
< L >
60
at_scope_exit
( L && l )
61
{
62
return
scope_exit_details
::
at_exit_t
<L>{ std::forward<L>(l) };
63
}
64
65
}
/* namespace utils */
66
67
}
/* namespace restinio */
restinio::utils::scope_exit_details::at_exit_t
Helper class for scope exit implementation.
Definition
at_scope_exit.hpp:32
restinio::utils::scope_exit_details::at_exit_t::m_lambda
L m_lambda
Definition
at_scope_exit.hpp:33
restinio::utils::scope_exit_details::at_exit_t::at_exit_t
at_exit_t(L &&l)
Definition
at_scope_exit.hpp:35
restinio::utils::scope_exit_details::at_exit_t::~at_exit_t
~at_exit_t()
Definition
at_scope_exit.hpp:37
restinio::utils::scope_exit_details::at_exit_t::at_exit_t
at_exit_t(at_exit_t &&o)
Definition
at_scope_exit.hpp:36
restinio::utils::scope_exit_details
Definition
at_scope_exit.hpp:25
restinio::utils
Definition
from_string_details.ipp:5
restinio::utils::at_scope_exit
scope_exit_details::at_exit_t< L > at_scope_exit(L &&l)
Helper function for creation action to be performed at scope exit.
Definition
at_scope_exit.hpp:60
restinio
Definition
sendfile_operation_default.ipp:12
Generated by
1.14.0