params(params),
scheduler(scheduler),
action_trace(),
- thread_map(),
+ thread_map(2), /* We'll always need at least 2 threads */
obj_map(new HashTable<const void *, action_list_t *, uintptr_t, 4>()),
condvar_waiters_map(),
obj_thrd_map(),
{
/* Initialize a model-checker thread, for special ModelActions */
model_thread = new Thread(get_next_id());
- thread_map.put(id_to_int(model_thread->get_id()), model_thread);
+ add_thread(model_thread);
scheduler->register_engine(this);
}
ModelExecution::~ModelExecution()
{
for (unsigned int i = 0; i < get_num_threads(); i++)
- delete thread_map.get(i);
+ delete get_thread(int_to_id(i));
delete obj_map;
*/
void ModelExecution::add_thread(Thread *t)
{
- thread_map.put(id_to_int(t->get_id()), t);
+ unsigned int i = id_to_int(t->get_id());
+ if (i >= thread_map.size())
+ thread_map.resize(i + 1);
+ thread_map[i] = t;
if (!t->is_model_thread())
scheduler->add_thread(t);
}
*/
Thread * ModelExecution::get_thread(thread_id_t tid) const
{
- return thread_map.get(id_to_int(tid));
+ unsigned int i = id_to_int(tid);
+ if (i < thread_map.size())
+ return thread_map[i];
+ return NULL;
}
/**
ModelAction * get_uninitialized_action(const ModelAction *curr) const;
action_list_t action_trace;
- HashTable<int, Thread *, int> thread_map;
+ SnapVector<Thread *> thread_map;
/** Per-object list of actions. Maps an object (i.e., memory location)
* to a trace of all actions performed on the object. */