From f06cd40fb350723b2dbe59f8c494b03a60f41b40 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 5 Feb 2013 14:03:28 -0800 Subject: [PATCH] promise: add is_compatible_exclusive() Check if a Promise is both compatible *and* exclusive to a particular thread. This allows ordering optimizations when we can guarantee that a particular thread must fulfill the promise. --- promise.cc | 13 ++++++++++++- promise.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/promise.cc b/promise.cc index fdd4579..ea5e7e6 100644 --- a/promise.cc +++ b/promise.cc @@ -83,5 +83,16 @@ bool Promise::has_failed() const */ bool Promise::is_compatible(const ModelAction *write) const { - return thread_is_available(write->get_tid()); + return thread_is_available(write->get_tid()) && read->same_var(write); +} + +/** + * @brief Check if a promise is compatible with a store and is exclusive to its + * thread + * @param write The store to check against + * @return True if we are compatible and exclusive; false otherwise + */ +bool Promise::is_compatible_exclusive(const ModelAction *write) const +{ + return get_num_available_threads() == 1 && is_compatible(write); } diff --git a/promise.h b/promise.h index e040e16..178b86e 100644 --- a/promise.h +++ b/promise.h @@ -42,6 +42,7 @@ class Promise { const ModelAction * get_write() const { return write; } int get_num_available_threads() const { return num_available_threads; } bool is_compatible(const ModelAction *write) const; + bool is_compatible_exclusive(const ModelAction *write) const; void print() const; -- 2.34.1