mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-25 22:26:24 +00:00
19 lines
No EOL
413 B
C++
19 lines
No EOL
413 B
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
#pragma once
|
|
|
|
template <typename T>
|
|
std::shared_ptr<T> PheonixSingleton() {
|
|
static std::weak_ptr<T> instance_;
|
|
static std::mutex lock_;
|
|
|
|
std::lock_guard<std::mutex> lock(lock_);
|
|
if (auto instance = instance_.lock()) {
|
|
return instance;
|
|
}
|
|
|
|
auto instance = std::make_shared<T>();
|
|
instance_ = instance;
|
|
return instance;
|
|
} |