summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdbx
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-12 14:39:55 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-12 14:39:55 +0300
commitc8e2e4951c4e98b457c49c9083196a2fe31e4e43 (patch)
tree046beb72cb83fbcb54f8cb0afef4d3651c165378 /plugins/Dbx_mdbx
parentdd1fc18d107a2cac81acdd8055403bf8d8ca7413 (diff)
this solution is too smart, smth goes wrong with it => KISS principle rulez
Diffstat (limited to 'plugins/Dbx_mdbx')
-rw-r--r--plugins/Dbx_mdbx/src/stdafx.h35
1 files changed, 13 insertions, 22 deletions
diff --git a/plugins/Dbx_mdbx/src/stdafx.h b/plugins/Dbx_mdbx/src/stdafx.h
index 2e50a70e8b..5a14b7ab6f 100644
--- a/plugins/Dbx_mdbx/src/stdafx.h
+++ b/plugins/Dbx_mdbx/src/stdafx.h
@@ -91,18 +91,15 @@ public:
/* FIXME: throw an exception */
assert(rc == MDBX_SUCCESS);
UNREFERENCED_PARAMETER(rc);
- m_txn = NULL;
+ m_txn = nullptr;
}
};
struct CMDBX_txn_ro
{
- MDBX_txn *m_txn;
- bool bIsActive;
+ MDBX_txn *m_txn = nullptr;
mir_cs cs;
- __forceinline CMDBX_txn_ro() : m_txn(nullptr), bIsActive(false) {}
-
__forceinline operator MDBX_txn* () { return m_txn; }
__forceinline MDBX_txn** operator &() { return &m_txn; }
};
@@ -110,28 +107,22 @@ struct CMDBX_txn_ro
class txn_ptr_ro
{
CMDBX_txn_ro &m_txn;
- bool bNeedReset;
mir_cslock lock;
+
public:
- __forceinline txn_ptr_ro(CMDBX_txn_ro &txn) : m_txn(txn), bNeedReset(!txn.bIsActive), lock(m_txn.cs)
+ __forceinline txn_ptr_ro(CMDBX_txn_ro &txn) : m_txn(txn), lock(m_txn.cs)
{
- if (bNeedReset) {
- int rc = mdbx_txn_renew(m_txn);
- /* FIXME: throw an exception */
- assert(rc == MDBX_SUCCESS);
- (void)rc;
- m_txn.bIsActive = true;
- }
+ int rc = mdbx_txn_renew(m_txn);
+ /* FIXME: throw an exception */
+ assert(rc == MDBX_SUCCESS);
+ UNREFERENCED_PARAMETER(rc);
}
__forceinline ~txn_ptr_ro()
{
- if (bNeedReset) {
- int rc = mdbx_txn_reset(m_txn);
- /* FIXME: throw an exception */
- assert(rc == MDBX_SUCCESS);
- (void)rc;
- m_txn.bIsActive = false;
- }
+ int rc = mdbx_txn_reset(m_txn);
+ /* FIXME: throw an exception */
+ assert(rc == MDBX_SUCCESS);
+ UNREFERENCED_PARAMETER(rc);
}
__forceinline operator MDBX_txn*() const { return m_txn; }
};
@@ -144,7 +135,7 @@ public:
__forceinline cursor_ptr(MDBX_txn *_txn, MDBX_dbi _dbi)
{
if (mdbx_cursor_open(_txn, _dbi, &m_cursor) != MDBX_SUCCESS)
- m_cursor = NULL;
+ m_cursor = nullptr;
}
__forceinline ~cursor_ptr()