| Flutter Impeller |

archive_transaction.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/archivist/archive_transaction.h"
6
7 #include "flutter/fml/logging.h"
8 #include "impeller/archivist/archive_statement.h"
9
10 namespace impeller {
11
12 ArchiveTransaction::ArchiveTransaction(int64_t& transactionCount,
13 ArchiveStatement& beginStatement,
14 ArchiveStatement& endStatement,
15 ArchiveStatement& rollbackStatement)
16 : end_stmt_(endStatement),
17 rollback_stmt_(rollbackStatement),
18 transaction_count_(transactionCount) {
19 if (transaction_count_ == 0) {
20 cleanup_ = beginStatement.Execute() == ArchiveStatement::Result::kDone;
21 }
22 transaction_count_++;
23 }
24
25 ArchiveTransaction::ArchiveTransaction(ArchiveTransaction&& other)
26 : end_stmt_(other.end_stmt_),
27 rollback_stmt_(other.rollback_stmt_),
28 transaction_count_(other.transaction_count_),
29 cleanup_(other.cleanup_),
30 successful_(other.successful_) {
31 other.abandoned_ = true;
32 }
33
34 ArchiveTransaction::~ArchiveTransaction() {
35 if (abandoned_) {
36 return;
37 }
38
39 FML_CHECK(transaction_count_ != 0);
40 if (transaction_count_ == 1 && cleanup_) {
41 auto res = successful_ ? end_stmt_.Execute() : rollback_stmt_.Execute();
42 FML_CHECK(res == ArchiveStatement::Result::kDone)
43 << "Must be able to commit the nested transaction";
44 }
45 transaction_count_--;
46 }
47
48 void ArchiveTransaction::MarkWritesAsReadyForCommit() {
49 successful_ = true;
50 }
51
52 } // namespace impeller
impeller::ArchiveStatement::Result::kDone
@ kDone
impeller::ArchiveStatement::Execute
Result Execute()
Execute the given statement with the provided data.
Definition: archive_statement.cc:217
archive_statement.h
impeller::ArchiveTransaction::MarkWritesAsReadyForCommit
void MarkWritesAsReadyForCommit()
Definition: archive_transaction.cc:48
impeller::ArchiveTransaction::ArchiveTransaction
ArchiveTransaction(ArchiveTransaction &&transaction)
Definition: archive_transaction.cc:25
archive_transaction.h
impeller::ArchiveTransaction::~ArchiveTransaction
~ArchiveTransaction()
Definition: archive_transaction.cc:34
impeller::ArchiveTransaction
All writes made to the archive within a transaction that is not marked as ready for commit will be ro...
Definition: archive_transaction.h:22
impeller
Definition: aiks_context.cc:10