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 Aug 21, 2024
1 parent 2dbc6c9 commit 0ba98a8
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 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 @@ -101,11 +114,15 @@ extern "C" {
safeInsert(timer_guid, task);
}
} else {
if (parent_count > 0) {
auto task = apex::new_task(timer_name, timer_guid, parent_tasks);
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(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 0ba98a8

Please sign in to comment.