Change mutex lock model to avoid dead lock and ensure locks are always released.

Additional cosmetic fixes:
 move 'name' as protected
 remove unnecessary local var
 Fix debug log
This commit is contained in:
cslashm 2018-03-26 12:38:38 +02:00
parent 641dfc991f
commit 100b7bc10d
5 changed files with 202 additions and 385 deletions

View file

@ -78,8 +78,10 @@ namespace hw {
return false;
}
class device {
protected:
std::string name;
public:
device() {}
@ -92,8 +94,6 @@ namespace hw {
static const int SIGNATURE_FAKE = 1;
std::string name;
/* ======================================================================= */
/* SETUP/TEARDOWN */
/* ======================================================================= */
@ -104,7 +104,15 @@ namespace hw {
virtual bool release() = 0;
virtual bool connect(void) = 0;
virtual bool disconnect() = 0;
virtual bool disconnect(void) = 0;
/* ======================================================================= */
/* LOCKER */
/* ======================================================================= */
virtual void lock(void) = 0;
virtual void unlock(void) = 0;
virtual bool try_lock(void) = 0;
/* ======================================================================= */
/* WALLET & ADDRESS */