-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread_controller.h
More file actions
50 lines (38 loc) · 1.3 KB
/
thread_controller.h
File metadata and controls
50 lines (38 loc) · 1.3 KB
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
#ifndef __MAIN_THREAD__
#define __MAIN_THREAD__
#include <vector>
#include <mutex>
#include <string>
#include "data_type.h"
#include "text_unshredder.h"
class ThreadController
{
#ifdef UTFLAG
public:
#else
private:
#endif
// mutex for all threads
static std::mutex status_mutex_;
static std::mutex data_mutex_;
// Default thread_status_ = NOTSTART
static ThreadStatus thread_status_;
// Called by DoTextUnshredderInThread
static void UpdateThreadStatus(ThreadStatus status);
// Called by DoTextUnshredderInThread
static void RecordThreadResult(std::vector<std::string> vec_final_merged_text, int n_premature_column_count, bool b_premature_flag);
// Called by DoTextUnshredderInThread
static void RecordThreadAbnormals();
public:
// Default is 0, the number will be increased if any exception throw from a thread
static int n_thread_abnormals_;
// Store final result
static std::vector<std::string> vec_final_merged_text_;
// Default b_premature_flag_ = false
static bool b_premature_flag_;
// Size of unselected columns when premature happens, default n_premature_column_count_ = 0
static int n_premature_column_count_;
// Entry function for threads
static int DoTextUnshredderInThread(TextUnshredder text_unshred);
};
#endif