Initial commit
This commit is contained in:
+69
@@ -0,0 +1,69 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <ostream>
|
||||
#include <wfr/common/types/WfrTypes.h>
|
||||
#include <wfr/common/types/ResourceTypes.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace resource {
|
||||
|
||||
class AbstractResource;
|
||||
class ComputingResource;
|
||||
class ComputingResourceType;
|
||||
class ComputingResourceReservation;
|
||||
class RequiredResourceCapability;
|
||||
|
||||
class ResourceManager {
|
||||
private:
|
||||
static ResourceManager* singleton;
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
std::mutex managerMutex;
|
||||
std::map<std::string, ComputingResourceType*> computingResourceTypes;
|
||||
std::map<std::string, ComputingResource*> computingResources;
|
||||
|
||||
// Non-public functions
|
||||
private:
|
||||
ResourceManager(std::string resourceConfigFile, bool cpuAutoConfig, bool printResourceTable);
|
||||
|
||||
void readConfigFile(std::string configFile);
|
||||
|
||||
// Public static functions
|
||||
public:
|
||||
static void init(int argc, char** argv);
|
||||
static void finish() noexcept;
|
||||
static ResourceManager& getInstance() noexcept;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
~ResourceManager() noexcept;
|
||||
|
||||
wfr_size_t getComputingResourceCount() const noexcept { return computingResources.size(); }
|
||||
std::vector<ComputingResource*> getComputingResources() const noexcept;
|
||||
ComputingResource* getComputingResource(std::string identifier) const noexcept;
|
||||
std::vector<ComputingResource*> filterComputingResources(std::vector<RequiredResourceCapability> filter) const noexcept;
|
||||
|
||||
ComputingResourceReservation reserveComputingResource(ComputingResource* device, const wfr_size_t& slots = 1) noexcept;
|
||||
bool releaseComputingResources(ComputingResourceReservation* handle) noexcept;
|
||||
|
||||
wfr_size_t getComputingResourceTypeCount() const noexcept { return computingResourceTypes.size(); }
|
||||
std::vector<ComputingResourceType*> getComputingResourceTypes() const noexcept;
|
||||
ComputingResourceType* getComputingResourceType(std::string name) const noexcept;
|
||||
|
||||
void printResourceTable(std::ostream& out) const noexcept;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace resource */
|
||||
} /* namespace wfr */
|
||||
|
||||
Reference in New Issue
Block a user