Skip to content

Commit

Permalink
For now, don't delete tasks from the guid map. it's possible that the…
Browse files Browse the repository at this point in the history
… parent has been completed and destroyed before the child has even been created.
  • Loading branch information
khuck committed Jul 29, 2024
1 parent 70f0e5a commit 84bba28
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/apex/taskstubs_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ maptype& getMyMap(void) {
return theMap;
}

void safePrint(const char * format, tasktimer_guid_t guid) {
return;
std::scoped_lock lock{mtx};
printf("%lu %s GUID %lu\n", apex::thread_instance::get_id(), format, guid);
}

void safeInsert(
tasktimer_guid_t guid,
std::shared_ptr<apex::task_wrapper> task) {
mtx.lock();
getCommonMap()[guid] = task;
mtx.unlock();
getMyMap()[guid] = task;
//safePrint("Inserted", guid);
}

std::shared_ptr<apex::task_wrapper> safeLookup(
Expand All @@ -46,19 +53,25 @@ std::shared_ptr<apex::task_wrapper> safeLookup(
task = getCommonMap().find(guid);
mtx.unlock();
if (task == getCommonMap().end()) {
safePrint("Not found", guid);
return nullptr;
}
getMyMap()[guid] = task->second;
}
//safePrint("Found", guid);
return task->second;
}

void safeErase(
tasktimer_guid_t guid) {
return;
/*
getMyMap().erase(guid);
mtx.lock();
getCommonMap().erase(guid);
mtx.unlock();
//safePrint("Destroyed", guid);
*/
}

extern "C" {
Expand Down Expand Up @@ -102,12 +115,15 @@ extern "C" {
safeInsert(timer_guid, task);
}
} else {
std::string tmpname{timer_name};
//tmpname += std::string(" ");
//tmpname += std::to_string(timer_guid);
// TODO: need to handle multiple parents!
if (parent_tasks.size() > 0) {
auto task = apex::new_task(timer_name, timer_guid, parent_tasks[0]);
auto task = apex::new_task(tmpname, timer_guid, parent_tasks);
safeInsert(timer_guid, task);
} else {
auto task = apex::new_task(timer_name, timer_guid);
auto task = apex::new_task(tmpname, timer_guid);
safeInsert(timer_guid, task);
}
}
Expand Down

0 comments on commit 84bba28

Please sign in to comment.