flat pool

This commit is contained in:
malloc 2018-04-11 16:28:00 -05:00
parent 7aa1a28a46
commit 470bf21c43

View file

@ -1,6 +1,11 @@
#ifndef SOSC_POOL_H #ifndef SOSC_POOL_H
#define SOSC_POOL_H #define SOSC_POOL_H
#include <vector>
#include <list>
#include <thread>
#include <mutex>
namespace sosc { namespace sosc {
template<typename T> template<typename T>
class Pool { class Pool {
@ -9,7 +14,21 @@ public:
protected: protected:
virtual void ProcessClient(T* client) = 0; virtual void ProcessClient(T* client) = 0;
private: private:
class Stack {
public:
private:
std::thread thread;
std::list<T*> clients;
std::mutex clients_mtx;
Pool<T> *pool;
friend class Pool<T>;
};
std::vector<Stack> stacks;
friend class Stack;
}; };
} }