Skip to content

Commit

Permalink
Delete event during deferred callback (iree-org#15303)
Browse files Browse the repository at this point in the history
Deleting an event should be deferred until the event is triggered. This
avoids the issue where an event deletion depends on something already
locked.
  • Loading branch information
rsuderman authored Oct 26, 2023
1 parent 5b43ed0 commit 41c2b6d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion integrations/pjrt/src/iree_pjrt/common/api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,16 @@ EventInstance::~EventInstance() {
void EventInstance::BindApi(PJRT_Api* api) {
api->PJRT_Event_Destroy = +[](PJRT_Event_Destroy_Args* args) -> PJRT_Error* {
IREE_TRACE_SCOPE_NAMED("PJRT_Event_Destroy");
delete EventInstance::Unwrap(args->event);
auto instance = EventInstance::Unwrap(args->event);
auto delete_event = [](PJRT_Error* error, void* user_data) {
EventInstance* event = static_cast<EventInstance*>(user_data);
delete event;
if (error) {
delete ErrorInstance::FromError(error);
}
};

instance->OnReady(delete_event, args->event);
return nullptr;
};
api->PJRT_Event_IsReady = +[](PJRT_Event_IsReady_Args* args) -> PJRT_Error* {
Expand Down

0 comments on commit 41c2b6d

Please sign in to comment.