refactor DBG_ENABLED() vs. verbose
[model-checker.git] / action.cc
index 1007e762ee5258305bbd8ef5b403db5a874f17cc..be8c4a6c0cdc69bde75fd08436a33705fa9157af 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -651,3 +651,17 @@ bool ModelAction::may_read_from(const Promise *promise) const
                        return true;
        return false;
 }
+
+/**
+ * Only valid for LOCK, TRY_LOCK, UNLOCK, and WAIT operations.
+ * @return The mutex operated on by this action, if any; otherwise NULL
+ */
+std::mutex * ModelAction::get_mutex() const
+{
+       if (is_trylock() || is_lock() || is_unlock())
+               return (std::mutex *)get_location();
+       else if (is_wait())
+               return (std::mutex *)get_value();
+       else
+               return NULL;
+}