Skip to content

Commit

Permalink
Simplify code of Communicator::deinit(). (#1699)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim authored Feb 19, 2025
1 parent 4bf00f8 commit 2f06cbb
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/kernel/Communicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1242,19 +1242,12 @@ void Communicator::handler_thread_routine(void *context)
break;
default:
free(res);
if (comm->thrdpool)
thrdpool_exit(comm->thrdpool);
continue;
thrdpool_exit(comm->thrdpool);
return;
}

free(res);
}

if (!comm->thrdpool)
{
mpoller_destroy(comm->mpoller);
msgqueue_destroy(comm->msgqueue);
}
}

int Communicator::append_message(const void *buf, size_t *size,
Expand Down Expand Up @@ -1608,15 +1601,12 @@ int Communicator::init(size_t poller_threads, size_t handler_threads)

void Communicator::deinit()
{
int in_handler = this->is_handler_thread();

this->stop_flag = 1;
mpoller_stop(this->mpoller);
msgqueue_set_nonblock(this->msgqueue);
thrdpool_destroy(NULL, this->thrdpool);
this->thrdpool = NULL;
if (!in_handler)
Communicator::handler_thread_routine(this);
mpoller_destroy(this->mpoller);
msgqueue_destroy(this->msgqueue);
}

int Communicator::nonblock_connect(CommTarget *target)
Expand Down

0 comments on commit 2f06cbb

Please sign in to comment.