CNum 0.2.1
CPU-optimized ML library for C++
Loading...
Searching...
No Matches
ModelPool.h
Go to the documentation of this file.
1#ifndef MODEL_POOL_H
2#define MODEL_POOL_H
4#include <memory>
5#include <vector>
6
7namespace CNum::Model {
12 template <typename ModelType>
13 class ModelPool {
14 private:
15 size_t _n_models;
17 ::std::vector<ModelType *> _model_ptrs;
18
19 public:
20
22 /// @param n_models The number of models in the pool
23 ModelPool(::std::string path, size_t n_models = 20);
24
25 ModelPool(const ModelPool &) = delete;
26 ModelPool &operator=(const ModelPool &) = delete;
27
30
33 ModelType *pull();
34
37 void push(ModelType *model);
38 };
39
40 #include "CNum/Model/ModelPool.tpp"
41};
42
43#endif
Coarse-grained locking concurrent queue.
Definition ConcurrentQueue.h:23
ModelPool(const ModelPool &)=delete
ModelType * pull()
Pull a model from the pool.
Definition ModelPool.h:22
~ModelPool()
Destructor.
Definition ModelPool.h:16
ModelPool(::std::string path, size_t n_models=20)
Overloaded default constructor.
Definition ModelPool.h:3
ModelPool & operator=(const ModelPool &)=delete
void push(ModelType *model)
Push a model to the pool model A raw pointer to a trained model pulled from the pool.
Definition ModelPool.h:29
The namespace containing the ML models in CNum.