-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_tree.h
More file actions
44 lines (33 loc) · 1.07 KB
/
Copy pathtask_tree.h
File metadata and controls
44 lines (33 loc) · 1.07 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
#ifndef __TASK_TREE__H__
#define __TASK_TREE__H__
#include "expression_parser.h"
#include "task.h"
#include <future>
#include <memory>
namespace NThread {
class TThreadPool;
}
namespace NTask {
template <typename TData>
class TTaskTree {
friend class NThread::TThreadPool;
public:
// Constructor based on rawTree
TTaskTree(const NRawTree::TRawTree<std::string_view>& rawTree,
std::vector<TData> data,
const std::unordered_map<std::string, TOperation<TData>>& dictionary);
private:
void BuildTree(size_t root,
size_t level, // Level represents first index of the task in Tasks_.
const NRawTree::TRawTree<std::string_view>& rawTree,
std::vector<std::shared_future<TData>>& futures,
std::vector<bool>& visited,
NConcurrentArithmetics::NExpressionParser::TTaskParser<TData>& parser);
private:
using TTaskPtr = std::unique_ptr<TTaskBase<TData>>;
// Each subvector represents a tree level. The root is on the 0th level.
std::vector<std::vector<TTaskPtr>> Tasks_;
};
#include "task_tree_impl.h"
} // NTask
#endif