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 QUEUE_MANAGER_H 12 : #define QUEUE_MANAGER_H 13 : 14 : #include <mutex> 15 : #include <memory> 16 : #include <map> 17 : #include "acl_rt_impl.h" 18 : #include "queue_process.h" 19 : #include "queue.h" 20 : 21 : namespace acl { 22 : using QueueProcessorPtr = std::unique_ptr<QueueProcessor>; 23 : 24 : enum RunEnv : int32_t { 25 : ACL_ACL_ENV_UNKNOWN = -1, 26 : ACL_ENV_HOST = 0, 27 : ACL_ENV_DEVICE_CCPU = 1, 28 : ACL_ENV_DEVICE_SP = 2, 29 : }; 30 : 31 : class QueueManager { 32 : public: 33 : /** 34 : * Get queue manager instance 35 : * @return QueueManager reference 36 : */ 37 : static QueueManager& GetInstance(); 38 : 39 : /** 40 : * Get queue processor 41 : * @return queueProcessorPtr queue processor pointer 42 : */ 43 : QueueProcessor *GetQueueProcessor(); 44 : 45 : static aclError GetRunningEnv(RunEnv &runningEnv); 46 : 47 3 : QueueManager() = default; 48 : 49 3 : ~QueueManager() = default; 50 : 51 : // not allow copy constructor and assignment operators 52 : QueueManager(const QueueManager &) = delete; 53 : 54 : QueueManager &operator=(const QueueManager &) = delete; 55 : 56 : QueueManager(QueueManager &&) = delete; 57 : 58 : QueueManager &&operator=(QueueManager &&) = delete; 59 : 60 : private: 61 : // queue processor 62 : QueueProcessorPtr queueProcessProc_ = nullptr; 63 : RunEnv env_ = ACL_ACL_ENV_UNKNOWN; 64 : std::mutex muCreateProcessProc_; 65 : }; 66 : 67 : } 68 : 69 : #endif // QUEUE_MANAGER_H