LCOV - code coverage report
Current view: top level - basic_component/package_manager/inc - package_worker.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 5 5
Test Date: 2026-07-28 10:52:48 Functions: 100.0 % 2 2

            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              : #ifndef TSD_PACKAGE_WORKER_H
      12              : #define TSD_PACKAGE_WORKER_H
      13              : 
      14              : #include <map>
      15              : #include <mutex>
      16              : #include <array>
      17              : #include <memory>
      18              : #include "package_worker_factory.h"
      19              : 
      20              : namespace tsd {
      21              : class PackageWorker {
      22              : public:
      23            3 :     explicit PackageWorker(const uint32_t devId, const uint32_t vfId)
      24            3 :         : deviceId_(devId), vfId_(vfId), isDestroy_(false), workers_({})
      25              :     {
      26            3 :         workers_.fill(nullptr);
      27            3 :     };
      28              : 
      29            3 :     ~PackageWorker() { Stop(); };
      30              : 
      31              :     static std::shared_ptr<PackageWorker> GetInstance(const uint32_t devId, const uint32_t vfId);
      32              :     TSD_StatusT LoadPackage(const PackageWorkerType type, const std::string& path, const std::string& fileName);
      33              :     TSD_StatusT UnloadPackage(const PackageWorkerType type);
      34              :     uint64_t GetPackageCheckCode(const PackageWorkerType type);
      35              :     void ClearPackageCheckCode(const PackageWorkerType type);
      36              :     std::shared_ptr<BasePackageWorker> GetPackageWorker(const PackageWorkerType type);
      37              :     void DestroyPackageWorker();
      38              :     void SetAsanMode(const bool isAsan);
      39              : 
      40              : private:
      41              :     void Stop() noexcept;
      42              :     void ClearWorkerManager();
      43              : 
      44              :     uint32_t deviceId_;
      45              :     uint32_t vfId_;
      46              :     bool isDestroy_;
      47              :     std::mutex workersMutex_;
      48              :     std::array<std::shared_ptr<BasePackageWorker>, (static_cast<size_t>(PackageWorkerType::PACKAGE_WORKER_MAX) + 1UL)>
      49              :         workers_;
      50              :     static std::mutex workerManagerMutex_;
      51              :     static std::map<std::pair<uint32_t, uint32_t>, std::shared_ptr<PackageWorker>> workerManager_;
      52              : };
      53              : } // namespace tsd
      54              : #endif // TSD_PACKAGE_WORKER_H
        

Generated by: LCOV version 2.0-1