MeshLib C++ Docs
Loading...
Searching...
No Matches
MRParallelProgressReporter.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#include <MRPch/MRBindingMacros.h>
4#include <forward_list>
5#include <atomic>
6#include <thread>
7#include <mutex>
8
9
10namespace MR
11{
12
17class MR_BIND_IGNORE ParallelProgressReporter
18{
19public:
21
22 struct TaskInfo
23 {
24 float progress = 0.f;
25 float weight = 1.f;
26 };
27
31 {
32 MRMESH_API bool operator()( float p ) const;
33 ParallelProgressReporter* reporter_ = nullptr;
34 TaskInfo* task_ = nullptr;
35 };
36
37
41 MRMESH_API PerTaskReporter newTask( float weight = 1.f );
42
47
48private:
50 bool updateTask_( float delta );
51
52 const ProgressCallback& cb_;
53
55 std::forward_list<TaskInfo> perTaskInfo_;
56
58 float totalWeight_ = 0;
59
61 float progress_ = 0;
62
63 bool continue_ = true;
64
65 std::mutex mutex_;
66
68 std::thread::id mainThreadId_;
69};
70
71}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
Definition MRParallelProgressReporter.h:18
MRMESH_API bool operator()()
MRMESH_API ParallelProgressReporter(const ProgressCallback &cb)
MRMESH_API PerTaskReporter newTask(float weight=1.f)
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:626
Definition MRParallelProgressReporter.h:31
MRMESH_API bool operator()(float p) const
Definition MRParallelProgressReporter.h:23