promise: rewrite into a simpler header file
authorBrian Norris <banorris@uci.edu>
Mon, 20 Aug 2012 19:11:42 +0000 (12:11 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 20 Aug 2012 23:18:07 +0000 (16:18 -0700)
Makefile
promise.cc [deleted file]
promise.h

index 9812ab47519c10831ad4aff9a1588026479d2c8a..2acdbc7dff8a7738c6f99349421aa66bc97b5d5b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ include common.mk
 
 OBJECTS = libthreads.o schedule.o model.o threads.o librace.o action.o \
          nodestack.o clockvector.o main.o snapshot-interface.o cyclegraph.o \
-         datarace.o impatomic.o cmodelint.o promise.o \
+         datarace.o impatomic.o cmodelint.o \
          snapshot.o malloc.o mymemory.o
 
 CPPFLAGS += -Iinclude -I.
diff --git a/promise.cc b/promise.cc
deleted file mode 100644 (file)
index b051ef0..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "promise.h"
-
-Promise::Promise(ModelAction *act, uint64_t value) {
-       this->value=value;
-       this->read=act;
-       this->numthreads=1;
-}
-
index fda00cc508229221e5965ea3c752443d503bb1ca..d729e0309868846425d0c439962187b7aa83de44 100644 (file)
--- a/promise.h
+++ b/promise.h
@@ -6,21 +6,23 @@
 
 #ifndef __PROMISE_H__
 #define __PROMISE_H__
-#include <inttypes.h>
 
+#include <inttypes.h>
 
 class ModelAction;
 
 class Promise {
  public:
-       Promise(ModelAction * act, uint64_t value);
-       ModelAction * get_action() { return read; }
+       Promise(ModelAction *act, uint64_t value) :
+               value(value), read(act), numthreads(1)
+       { }
+       ModelAction * get_action() const { return read; }
        int increment_threads() { return ++numthreads; }
-       uint64_t get_value() { return value; }
+       uint64_t get_value() const { return value; }
 
  private:
-       uint64_t value;
-       ModelAction *read;
+       const uint64_t value;
+       ModelAction * const read;
        unsigned int numthreads;
 };