NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::scope_transaction< Connect > 模板类 参考

RAII事务作用域守卫 更多...

#include <scope_transaction.hpp>

Public 成员函数

 scope_transaction (Connect &conn)
 构造函数,开始事务
 ~scope_transaction () noexcept
 析构函数
 scope_transaction (scope_transaction &&other) noexcept
 移动构造函数
scope_transactionoperator= (scope_transaction &&other) noexcept
 移动赋值运算符
void commit ()
 提交事务
bool committed () const noexcept
 检查事务是否已提交

详细描述

template<typename Connect>
class neforce::scope_transaction< Connect >

RAII事务作用域守卫

管理数据库事务的生命周期:

  • 构造时调用 begin()
  • commit() 显式提交事务(仅可调用一次)
  • 析构时若未提交则调用 rollback()

不可复制,支持移动语义。

模板参数
Connect连接类型,需满足 idb_connect 接口(提供 begin/commit/rollback)

在文件 scope_transaction.hpp45 行定义.

构造及析构函数说明

◆ scope_transaction() [1/2]

template<typename Connect>
neforce::scope_transaction< Connect >::scope_transaction ( Connect & conn)
inlineexplicit

构造函数,开始事务

参数
conn数据库连接引用

立即调用 conn.begin() 开始事务。

在文件 scope_transaction.hpp57 行定义.

被这些函数引用 operator=() , 以及 scope_transaction().

◆ ~scope_transaction()

template<typename Connect>
neforce::scope_transaction< Connect >::~scope_transaction ( )
inlinenoexcept

析构函数

如果事务未提交,自动调用 rollback() 回滚。 如果事务已提交,不做任何操作。

在文件 scope_transaction.hpp68 行定义.

◆ scope_transaction() [2/2]

template<typename Connect>
neforce::scope_transaction< Connect >::scope_transaction ( scope_transaction< Connect > && other)
inlinenoexcept

移动构造函数

参数
other源对象

移动后源对象变为无效状态,不再持有连接引用。

在文件 scope_transaction.hpp88 行定义.

引用了 scope_transaction().

成员函数说明

◆ commit()

template<typename Connect>
void neforce::scope_transaction< Connect >::commit ( )
inline

提交事务

调用 conn.commit() 提交事务,并将守卫标记为已提交。 已提交的守卫在析构时不会回滚。 重复调用无效。

在文件 scope_transaction.hpp127 行定义.

◆ committed()

template<typename Connect>
bool neforce::scope_transaction< Connect >::committed ( ) const
inlinenodiscardnoexcept

检查事务是否已提交

返回
已提交返回true

在文件 scope_transaction.hpp138 行定义.

◆ operator=()

template<typename Connect>
scope_transaction & neforce::scope_transaction< Connect >::operator= ( scope_transaction< Connect > && other)
inlinenoexcept

移动赋值运算符

参数
other源对象
返回
自身引用

如果当前守卫未提交,先回滚当前事务。

在文件 scope_transaction.hpp102 行定义.

引用了 neforce::addressof() , 以及 scope_transaction().


该类的文档由以下文件生成: