-
Notifications
You must be signed in to change notification settings - Fork 6
/
forms.cpp
51 lines (41 loc) · 962 Bytes
/
forms.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <sstream>
#include "forms.h"
bool operator==(const Form& a, const Form& b)
{
return a.id == b.id;
}
bool operator!=(const Form& a, const Form& b)
{
return a.id != b.id;
}
void Form::log(const std::string& msg, const LogType& t)
{
std::ostringstream s;
s << t << ": " << msg << std::endl;
std::unique_lock<std::mutex> lock(output_mutex);
output += s.str();
}
Form::Form(Form&& f)
: id(f.id), key(f.key), pages(f.pages), processor(f.processor)
{
filename = std::move(f.filename);
formImages = std::move(f.formImages);
{
std::unique_lock<std::mutex> lock1(f.done_mutex);
done = f.done;
}
{
std::unique_lock<std::mutex> lock2(f.output_mutex);
output = std::move(f.output);
}
}
void Form::incDone()
{
std::unique_lock<std::mutex> lock(done_mutex);
++done;
}
long long Form::getDone()
{
std::unique_lock<std::mutex> lock(done_mutex);
return done;
}