/**
* A guard struct for thread synchronization and transaction management.
*/
- typedef std::shared_ptr<void> Transaction;
+ class Transaction {
+ public:
+ Transaction(KVStore& store);
+ ~Transaction();
+
+ Transaction(const Transaction&) = delete;
+ Transaction& operator=(const Transaction&) = delete;
+
+ void commit();
+ private:
+ std::unique_lock<std::recursive_mutex> mLock;
+ KVStore& mKVStore;
+ bool mIsOuter;
+ };
/**
* @param path configuration database file path
*/
std::vector<std::string> getKeys();
- KVStore::Transaction getTransaction();
-
private:
typedef std::lock_guard<std::recursive_mutex> Lock;
- struct TransactionImpl;
- std::weak_ptr<TransactionImpl> mTransactionImplPtr;
std::recursive_mutex mMutex;
+ size_t mTransactionDepth;
+ bool mIsTransactionCommited;
void setInternal(const std::string& key, const std::string& value);
void setInternal(const std::string& key, const std::initializer_list<std::string>& values);