From 2fe9e355a92ccc7e489145b624f857155297fe63 Mon Sep 17 00:00:00 2001 From: silverice Date: Tue, 15 Mar 2016 22:28:42 +0300 Subject: [PATCH] less strict locking --- JContainers/src/collections/dyn_form_watcher.hpp | 14 +++++++++----- JContainers/src/collections/item.h | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/JContainers/src/collections/dyn_form_watcher.hpp b/JContainers/src/collections/dyn_form_watcher.hpp index d1a17fe4..322fa450 100644 --- a/JContainers/src/collections/dyn_form_watcher.hpp +++ b/JContainers/src/collections/dyn_form_watcher.hpp @@ -176,13 +176,15 @@ namespace collections { auto itr = _watched_forms.find(formId); if (itr != _watched_forms.end()) { - std::lock_guard guard{ spinlock_for(formId) }; auto watched = itr->second.lock(); if (watched) { watched->set_deleted(); - itr->second.reset(); - + { + // the only unsafe piece of code here + std::lock_guard guard{ spinlock_for(formId) }; + itr->second.reset(); + } log("flagged form-entry %" PRIX32 " as deleted", formId); } } @@ -256,12 +258,14 @@ namespace collections { } { - std::lock_guard guard{ spinlock_for(fId) }; auto itr = _watched_forms.find(fId); + + std::lock_guard guard{ spinlock_for(fId) }; + if (itr != _watched_forms.end()) { auto watched = itr->second.lock(); - if (!watched) { + if (!watched || watched->is_deleted()) { // form-entry and real form has been deleted (recently) // watch the form again, create entry, assuming that a new form with such ID exists diff --git a/JContainers/src/collections/item.h b/JContainers/src/collections/item.h index c2f75ca8..861061c2 100644 --- a/JContainers/src/collections/item.h +++ b/JContainers/src/collections/item.h @@ -193,9 +193,10 @@ namespace collections { else if (auto val = boost::get(&_var)) { return *val; } - else if (auto val = boost::get(&_var)) { + // ability to read forms as integer values. likely not needed anymore + /*else if (auto val = boost::get(&_var)) { return static_cast(val->get_raw()); - } + }*/ return 0; }