From cb9b254332794ea63d0089b21b498f4a5301f08b Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Thu, 21 Jun 2012 01:56:50 -0700 Subject: [PATCH] action: add happens_before() function Now I can easily compare two ModelActions with the happens_before() relationship. Of course, the clock vectors are not fully complete yet, but this sets the stage... --- action.cc | 11 +++++++++++ action.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/action.cc b/action.cc index 34650c63..9f95727c 100644 --- a/action.cc +++ b/action.cc @@ -133,6 +133,17 @@ void ModelAction::read_from(ModelAction *act) value = act->value; } +/** + * Check whether 'this' happens before act, according to the memory-model's + * happens before relation. This is checked via the ClockVector constructs. + * @return true if this action's thread has synchronized with act's thread + * since the execution of act, false otherwise. + */ +bool ModelAction::happens_before(ModelAction *act) +{ + return act->cv->synchronized_since(this); +} + void ModelAction::print(void) { const char *type_str; diff --git a/action.h b/action.h index f554e36c..ae4afb29 100644 --- a/action.h +++ b/action.h @@ -58,6 +58,8 @@ public: ClockVector * get_cv() const { return cv; } void read_from(ModelAction *act); + bool happens_before(ModelAction *act); + inline bool operator <(const ModelAction& act) const { return get_seq_number() < act.get_seq_number(); } -- 2.34.1