LCOV - code coverage report
Current view: top level - server/hccl - comm_channel_manager.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 22 22
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "hccl/comm_channel_manager.h"
      12              : 
      13              : namespace dgw {
      14           36 :     CommChannelManager &CommChannelManager::GetInstance()
      15              :     {
      16           36 :         static CommChannelManager instance;
      17           36 :         return instance;
      18              :     }
      19              : 
      20            5 :     uint32_t CommChannelManager::GetCommChannelId(const CommChannel &channel, const CommChannel *&channelPtr)
      21              :     {
      22            5 :         const std::lock_guard<std::mutex> commChannelLock(commChannelMapMutex_);
      23            5 :         const auto iter = commChannelMap_.find(channel);
      24            5 :         if (iter != commChannelMap_.end()) {
      25            2 :             channelPtr = &(iter->first);
      26            2 :             return iter->second;
      27              :         }
      28              :         // generate channel id
      29              :         static uint32_t channelId = 0U;
      30            3 :         const auto result = commChannelMap_.emplace(std::make_pair(channel, channelId));
      31            3 :         channelPtr = &(result.first->first);
      32            3 :         return channelId++;
      33            5 :     }
      34              : 
      35           31 :     FsmStatus CommChannelManager::DeleteCommChannel(const CommChannel &channel)
      36              :     {
      37           31 :         const std::lock_guard<std::mutex> commChannelLock(commChannelMapMutex_);
      38           31 :         const auto iter = commChannelMap_.find(channel);
      39           31 :         if (iter == commChannelMap_.end()) {
      40           28 :             BQS_LOG_WARN("Not find channel[%s] in commChannelMap_.", channel.ToString().c_str());
      41           28 :             return FsmStatus::FSM_SUCCESS;
      42              :         }
      43            3 :         (void)commChannelMap_.erase(iter);
      44            3 :         return FsmStatus::FSM_SUCCESS;
      45           31 :     }
      46              : }
        

Generated by: LCOV version 2.0-1