-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignature.h
37 lines (33 loc) · 969 Bytes
/
signature.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <atomic>
#include <thread>
#include <memory>
#include "blockdata.h"
#include <exception>
using namespace std;
class Signature
{
public:
Signature(const string &out_filename, int64_t blocks_count, int64_t thread_count = thread::hardware_concurrency());
void force_stop();
void join();
void appendData(SignatureData data);
private:
atomic_bool isStart_ = {false};
atomic_bool isWriterStart_ = {false};
vector<thread> threads_;
thread writerThread_;
condition_variable cv_data_available_;
mutex cv_data_available_mutex_;
condition_variable cv_write_available_;
mutex cv_write_available_mutex_;
DataQueue in_data_queue_;
DataQueue out_data_queue_;
const int digets_size_ = 16;
void workerLoop(int thread_id);
void calcHash(SignatureData data);
void writeData();
void throwException();
const string out_filename_;
const int64_t blocksCount_;
exception_ptr ep = nullptr;
};