mirror of
https://github.com/microsoft/mscclpp.git
synced 2026-05-13 09:46:00 +00:00
Communicator owns IB contexts
This commit is contained in:
@@ -15,9 +15,6 @@ namespace mscclpp {
|
||||
Communicator::Impl::Impl(std::shared_ptr<BaseBootstrap> bootstrap) : bootstrap_(bootstrap) {}
|
||||
|
||||
Communicator::Impl::~Impl() {
|
||||
for (auto& entry : ibContexts) {
|
||||
delete entry.second;
|
||||
}
|
||||
ibContexts.clear();
|
||||
}
|
||||
|
||||
@@ -26,11 +23,10 @@ IbCtx* Communicator::Impl::getIbContext(TransportFlags ibTransport) {
|
||||
auto it = ibContexts.find(ibTransport);
|
||||
if (it == ibContexts.end()) {
|
||||
auto ibDev = getIBDeviceName(ibTransport);
|
||||
IbCtx* ibCtx = new IbCtx(ibDev);
|
||||
ibContexts[ibTransport] = ibCtx;
|
||||
return ibCtx;
|
||||
ibContexts[ibTransport] = std::make_unique<IbCtx>(ibDev);
|
||||
return ibContexts[ibTransport].get();
|
||||
} else {
|
||||
return it->second;
|
||||
return it->second.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "proxy.hpp"
|
||||
#include "ib.hpp"
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
|
||||
namespace mscclpp {
|
||||
|
||||
@@ -15,7 +16,7 @@ class ConnectionBase;
|
||||
struct Communicator::Impl {
|
||||
mscclppComm_t comm;
|
||||
std::vector<std::shared_ptr<ConnectionBase>> connections;
|
||||
std::unordered_map<TransportFlags, IbCtx*> ibContexts;
|
||||
std::unordered_map<TransportFlags, std::unique_ptr<IbCtx>> ibContexts;
|
||||
std::shared_ptr<BaseBootstrap> bootstrap_;
|
||||
|
||||
Impl(std::shared_ptr<BaseBootstrap> bootstrap);
|
||||
|
||||
Reference in New Issue
Block a user