-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_read.h
47 lines (40 loc) · 1.33 KB
/
file_read.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
37
38
39
40
41
42
43
44
45
46
47
#ifndef FILE_READ_H
#define FILE_READ_H
/*
Start function of this class takes file name and
reads this file. Characters from file are split to
"segments" (segment length can be configured) and each
segment is pushed to TaskParallelizer stack. Then,
StringSearch threads are taking this segments from stack
and performing string search in segments.
FileRead function also handles programm output, so it
prints results in process_sub_results() function.
*/
#include <iostream>
#include <string>
#include <filesystem>
#include <cstdio>
#include "util/task_parallelizer.h"
#include "string_search.h"
#include "const.h"
namespace fs = filesystem;
using namespace std;
class FileRead : public TaskParallelizer<fs::path, segment*, result*, StringSearch>{
public:
FileRead(const struct job_details t_jobs[], const unsigned t_job_num,
TaskContainer* t_super_job_class = nullptr, const int t_id = -1);
virtual void start(fs::path &t_path);
~FileRead();
protected:
virtual void start();
void process_sub_results();
private:
const unsigned m_sbuf_len;
const unsigned m_overlap;
const unsigned m_rbuf_len;
fs::path m_file_path;
char* m_rbuf;
vector<segment*> garb_collect;
inline void clear_collector();
};
#endif