-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#128 Extract transaction related definitions in transaction.inl
- Loading branch information
Showing
2 changed files
with
70 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// Copyright (C) 2014-2017 Sebastian Jeckel. | ||
// Copyright (C) 2020-2023 Krylov Yaroslav. | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
|
||
#ifndef UREACT_DETAIL_TRANSACTION_INL | ||
#define UREACT_DETAIL_TRANSACTION_INL | ||
|
||
#include <cassert> | ||
|
||
#include <ureact/context.hpp> | ||
#include <ureact/detail/defines.hpp> | ||
#include <ureact/detail/graph_impl.hpp> | ||
|
||
UREACT_BEGIN_NAMESPACE | ||
|
||
UREACT_FUNC transaction::transaction( context ctx ) | ||
: m_context( std::move( ctx ) ) | ||
{ | ||
auto& graph = get_internals( m_context ).get_graph(); | ||
assert( !graph.is_propagation_in_progress() | ||
&& "Can't start transaction in the middle of the change propagation process" ); | ||
graph.start_transaction(); | ||
} | ||
|
||
UREACT_FUNC transaction::~transaction() | ||
{ | ||
finish_impl(); | ||
} | ||
|
||
UREACT_FUNC void transaction::finish() | ||
{ | ||
finish_impl(); | ||
} | ||
|
||
UREACT_FUNC void transaction::finish_impl() | ||
{ | ||
if( !m_finished ) | ||
{ | ||
get_internals( m_context ).get_graph().finish_transaction(); | ||
m_finished = true; | ||
} | ||
} | ||
|
||
namespace default_context | ||
{ | ||
|
||
UREACT_FUNC default_transaction::default_transaction() | ||
: transaction( default_context::get() ) | ||
{} | ||
|
||
} // namespace default_context | ||
|
||
UREACT_END_NAMESPACE | ||
|
||
#endif //UREACT_DETAIL_TRANSACTION_INL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters