diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-18 19:29:25 +0200 | 
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-18 19:29:25 +0200 | 
| commit | 2742eebed2dd5db4dbf187504c95eca70aa624f2 (patch) | |
| tree | 2fa837f02496afb3eb29182c8f19dd109ad87061 /dinput | |
| parent | a18ca7764abbe24b601885ef06fcc98f0b7ed10b (diff) | |
dinput: reduce init_lock scope
Diffstat (limited to 'dinput')
| -rw-r--r-- | dinput/dinput.cpp | 14 | 
1 files changed, 5 insertions, 9 deletions
diff --git a/dinput/dinput.cpp b/dinput/dinput.cpp index 93aca79a..138cac71 100644 --- a/dinput/dinput.cpp +++ b/dinput/dinput.cpp @@ -43,12 +43,8 @@ void dinput_handle::di_t::free_di()  void dinput_handle::di_t::ref_di()  { -    while (init_lock.test_and_set()) { /* busy loop */ } -      const int refcnt_ = refcnt.fetch_add(1) + 1; -    qDebug() << "start: dinput refcount now" << (refcnt_); - -    init_lock.clear(); +    qDebug() << "start: dinput refcount now" << refcnt_;  }  dinput_handle::di_t& dinput_handle::di_t::operator=(const di_t& new_di) @@ -66,19 +62,19 @@ dinput_handle::di_t& dinput_handle::di_t::operator=(const di_t& new_di)  void dinput_handle::di_t::unref_di()  { -    while (init_lock.test_and_set()) { /* busy loop */ } -      const int refcnt_ = refcnt.fetch_sub(1) - 1;      qDebug() << "exit: dinput refcount now" << refcnt_;      if (refcnt_ == 0)      { +        while (init_lock.test_and_set()) { /* busy loop */ } +          qDebug() << "exit: deleting di handle";          free_di(); -    } -    init_lock.clear(); +        init_lock.clear(); +    }  }  dinput_handle::di_t::di_t(LPDIRECTINPUT8& handle) : handle(&handle)  | 
