To remove an unnecessary use of global/public model->get_num_threads().
#include "action.h"
#include "common.h"
#include "promise.h"
-#include "model.h"
#include "threads-model.h"
/** Initializes a CycleGraph object. */
if (label) {
int first = 1;
fprintf(file, " [label=\"P%d, T", idx);
- for (unsigned int i = 0 ; i < model->get_num_threads(); i++)
+ for (unsigned int i = 0 ; i < promise->max_available_thread_idx(); i++)
if (promise->thread_is_available(int_to_id(i))) {
fprintf(file, "%s%u", first ? "": ",", i);
first = 0;
return available_thread[id];
}
+/**
+ * @brief Get an upper bound on the number of available threads
+ *
+ * Gets an upper bound on the number of threads in the available threads set,
+ * useful for iterating over "thread_is_available()".
+ *
+ * @return The upper bound
+ */
+unsigned int Promise::max_available_thread_idx() const
+{
+ return available_thread.size();
+}
+
/** @brief Print debug info about the Promise */
void Promise::print() const
{
bool eliminate_thread(thread_id_t tid);
void add_thread(thread_id_t tid);
bool thread_is_available(thread_id_t tid) const;
+ unsigned int max_available_thread_idx() const;
bool has_failed() const;
void set_write(const ModelAction *act) { write = act; }
const ModelAction * get_write() const { return write; }