-
Notifications
You must be signed in to change notification settings - Fork 0
/
job.h
66 lines (56 loc) · 1.5 KB
/
job.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include "barrier.h"
#include <chrono>
#include <vector>
class IJob {
public:
/**
* Run tasks
*/
auto run() -> void const;
/**
* Elapsed time at seconds
*/
auto elapsedTime() -> double const;
protected:
IJob(uint numThread, uint64_t numTask);
virtual auto run_intern()->void const = 0;
uint numThread;
uint64_t numTask;
std::chrono::time_point<std::chrono::system_clock> start, end;
private:
explicit IJob() = delete;
explicit IJob(const IJob &) = delete;
explicit IJob(IJob &&) = delete;
auto operator =(const IJob& )->IJob& = delete;
auto operator =(IJob&& )->IJob& = delete;
};
class OmpJob final : public IJob
{
public:
OmpJob(uint numThread, uint64_t numTask);
protected:
auto run_intern()->void const override final;
private:
explicit OmpJob() = delete;
explicit OmpJob(const OmpJob &) = delete;
explicit OmpJob(OmpJob &&) = delete;
auto operator =(const OmpJob&)->OmpJob& = delete;
auto operator =(OmpJob&&)->OmpJob& = delete;
};
class StdJob final : public IJob
{
public:
StdJob(std::shared_ptr<IBarrier> barrier, uint numThread, uint64_t numTask);
auto work(uint threadId) -> void const;
auto work2(uint threadId, std::shared_ptr<IBarrier> barrier) -> void const;
protected:
auto run_intern()->void const override final;
private:
explicit StdJob() = delete;
explicit StdJob(const StdJob &) = delete;
explicit StdJob(StdJob &&) = delete;
auto operator =(const StdJob&)->StdJob& = delete;
auto operator =(StdJob&&)->StdJob& = delete;
std::shared_ptr<IBarrier> barrier;
};