From 2742eebed2dd5db4dbf187504c95eca70aa624f2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 Aug 2016 19:29:25 +0200 Subject: dinput: reduce init_lock scope --- dinput/dinput.cpp | 14 +++++--------- 1 file 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) -- cgit v1.2.3