promise: add max_available_thread_idx() interface
[cdsspec-compiler.git] / promise.cc
index df86090a2335ff3e17c69d33a98c9d370903f199..3a38384721cd3dfdc59b25f59440b432cf62c87b 100644 (file)
@@ -100,6 +100,19 @@ bool Promise::thread_is_available(thread_id_t tid) const
        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
 {