Find a faster way to get currently executing thread's id
[c11tester.git] / model.cc
index c022e9e3baab9c716498992bc09e525fca61ce69..4cf5cc57fea4bb94c5998460c701a8b618264c3d 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -135,6 +135,18 @@ Thread * ModelChecker::get_current_thread() const
        return scheduler->get_current_thread();
 }
 
+/**
+ * Must be called from user-thread context (e.g., through the global
+ * thread_current_id() interface)
+ *
+ * @return The id of the currently executing Thread.
+ */
+thread_id_t ModelChecker::get_current_thread_id() const
+{
+       ASSERT(int_to_id(curr_thread_num) == get_current_thread()->get_id());
+       return int_to_id(curr_thread_num);
+}
+
 /**
  * @brief Choose the next thread to execute.
  *