mirror of https://github.com/GOSTSec/poolserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
806 B
47 lines
806 B
#ifndef DATAMGR_H_ |
|
#define DATAMGR_H_ |
|
|
|
#include <deque> |
|
#include <boost/thread.hpp> |
|
|
|
#include "Util.h" |
|
#include "Share.h" |
|
|
|
#define BULK_MIN 1 |
|
#define BULK_COUNT 50 |
|
|
|
template<class T> |
|
class DataMgr |
|
{ |
|
public: |
|
DataMgr() {} |
|
|
|
void Push(T data) |
|
{ |
|
boost::unique_lock<boost::mutex> lock(_datamutex); |
|
_datastore.push_back(data); |
|
} |
|
|
|
T Pop() |
|
{ |
|
boost::unique_lock<boost::mutex> lock(_datamutex); |
|
Share share = _datastore.front(); |
|
_datastore.pop_front(); |
|
return share; |
|
} |
|
|
|
size_t Size() |
|
{ |
|
boost::unique_lock<boost::mutex> lock(_datamutex); |
|
return _datastore.size(); |
|
} |
|
|
|
void Upload(); |
|
private: |
|
boost::mutex _datamutex; |
|
std::deque<T> _datastore; |
|
}; |
|
|
|
extern DataMgr<Share> sDataMgr; |
|
|
|
#endif
|
|
|