milvus/cpp/src/scheduler/SchedInst.h
wxyu d233de81ff MS-409 Using new scheduler
Former-commit-id: bde50afd3f74e5b17405de9c21d0b5852b81c5df
2019-08-23 21:07:01 +08:00

61 lines
1.3 KiB
C++

/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include "ResourceMgr.h"
#include "Scheduler.h"
#include <mutex>
#include <memory>
namespace zilliz {
namespace milvus {
namespace engine {
class ResMgrInst {
public:
static ResourceMgrPtr
GetInstance() {
if (instance == nullptr) {
std::lock_guard<std::mutex> lock(mutex_);
if (instance == nullptr) {
instance = std::make_shared<ResourceMgr>();
}
}
return instance;
}
private:
static ResourceMgrPtr instance;
static std::mutex mutex_;
};
class SchedInst {
public:
static SchedulerPtr
GetInstance() {
if (instance == nullptr) {
std::lock_guard<std::mutex> lock(mutex_);
if (instance == nullptr) {
instance = std::make_shared<Scheduler>(ResMgrInst::GetInstance());
}
}
return instance;
}
private:
static SchedulerPtr instance;
static std::mutex mutex_;
};
void
SchedServInit();
}
}
}