-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathworker.h
More file actions
39 lines (31 loc) · 1.03 KB
/
worker.h
File metadata and controls
39 lines (31 loc) · 1.03 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
#pragma once
#include "params.h"
#include "worker_thread.h"
#include "bitmap.h"
#include <vector>
#include <thread>
#include <mutex>
#include <deque>
#include <numeric>
class Worker
{
public:
Worker();
void calculate_and_save_hints(int num_threads, std::string filename);
bool read_hints_from_file(std::string filename);
void computation(int num_threads);
void save_image(std::string filename);
private:
std::vector<std::unique_ptr<WorkerThread>> threads;
std::mutex mu;
std::vector<Complex> hints;
std::vector<long> points;
int calculate_value(const double& x, const double& y) const;
bool good_point(const double& x, const double& y) const;
void calculate_hints_range(int low_r, int high_r, std::deque<int>& row_queue);
void calculate_hints(int num_threads);
void update_points_from_thread(std::unique_ptr<WorkerThread>& t);
void save_hints_to_file(std::string filename);
long calculate_histogram_interval(std::vector<long>& v) const;
std::vector<long> get_interval_points();
};