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;
+}
class Thread;
class Promise;
+namespace std {
+ class mutex;
+}
+
using std::memory_order;
using std::memory_order_relaxed;
using std::memory_order_acquire;
uint64_t get_return_value() const;
const ModelAction * get_reads_from() const { return reads_from; }
Promise * get_reads_from_promise() const { return reads_from_promise; }
+ std::mutex * get_mutex() const;
Node * get_node() const;
void set_node(Node *n) { node = n; }
*/
bool ModelChecker::process_mutex(ModelAction *curr)
{
- std::mutex *mutex = NULL;
+ std::mutex *mutex = curr->get_mutex();
struct std::mutex_state *state = NULL;
- if (curr->is_trylock() || curr->is_lock() || curr->is_unlock()) {
- mutex = (std::mutex *)curr->get_location();
+ if (mutex)
state = mutex->get_state();
- } else if (curr->is_wait()) {
- mutex = (std::mutex *)curr->get_value();
- state = mutex->get_state();
- }
switch (curr->get_type()) {
case ATOMIC_TRYLOCK: {