diff options
author | Ilya Kitaev <mbg033@gmail.com> | 2016-07-10 17:17:23 +0300 |
---|---|---|
committer | Ilya Kitaev <mbg033@gmail.com> | 2016-07-18 23:02:47 +0300 |
commit | 9d2cb4f36ca7220bb05217547b72710b870f6e57 (patch) | |
tree | e0ced3eede4406ef4f4a020c0dbc09764c2cc62e /src/wallet/api/wallet.h | |
parent | hack to successfull linking for MSYS2 (diff) | |
download | monero-9d2cb4f36ca7220bb05217547b72710b870f6e57.tar.xz |
WalletListener functionality
Diffstat (limited to 'src/wallet/api/wallet.h')
-rw-r--r-- | src/wallet/api/wallet.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index 0896f51ee..e9da05347 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -35,6 +35,9 @@ #include "wallet/wallet2.h" #include <string> +#include <thread> +#include <mutex> +#include <condition_variable> namespace Bitmonero { @@ -71,7 +74,7 @@ public: uint64_t balance() const; uint64_t unlockedBalance() const; bool refresh(); - + void refreshAsync(); PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, uint64_t amount, uint32_t mixin_count, PendingTransaction::Priority priority = PendingTransaction::Priority_Low); @@ -84,19 +87,33 @@ public: private: void clearStatus(); + void refreshThreadFunc(); + void doRefresh(); + void startRefresh(); + void stopRefresh(); private: friend class PendingTransactionImpl; friend class TransactionHistoryImpl; tools::wallet2 * m_wallet; - int m_status; + std::atomic<int> m_status; std::string m_errorString; std::string m_password; TransactionHistoryImpl * m_history; bool m_trustedDaemon; WalletListener * m_walletListener; Wallet2CallbackImpl * m_wallet2Callback; + + // multi-threaded refresh stuff + std::atomic<bool> m_refreshEnabled; + std::atomic<bool> m_refreshThreadDone; + std::atomic<int> m_refreshIntervalSeconds; + std::mutex m_refreshMutex; + std::mutex m_refreshMutex2; + std::condition_variable m_refreshCV; + std::thread m_refreshThread; + }; |