Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Thread.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/basic.h>
35#include <ogdf/basic/memory.h>
36
37#include <thread>
38
39namespace ogdf {
40
42
53class Thread : public std::thread {
54public:
55 Thread() : thread() { }
56
57 Thread(Thread&& other) : thread(std::move((thread &&) other)) { }
58
59 // Visual C++ 2013 Preview cannot compile that combination of variadic templates and lambda function (though it should).
60 // Therefore we use the version without function arguments for MSVC untils this works.
61#ifdef _MSC_VER
62 template<class Function>
63 explicit Thread(Function&& f)
64 : thread([&] {
65 f();
66 OGDF_ALLOCATOR::flushPool();
67 }) { }
68
69#else
70 template<class Function, class... Args>
71 explicit Thread(Function&& f, Args&&... args)
72 : thread(
73 [&](Args&&... tArgs) {
74 f(std::forward<Args>(tArgs)...);
75 OGDF_ALLOCATOR::flushPool();
76 },
77 std::forward<Args>(args)...) { }
78#endif
79
81 thread::operator=(std::move((thread &&) other));
82 return *this;
83 }
84};
85
86}
Basic declarations, included by all source files.
Threads supporting OGDF's memory management.
Definition Thread.h:53
Thread(Function &&f, Args &&... args)
Definition Thread.h:71
Thread(Thread &&other)
Definition Thread.h:57
Thread & operator=(Thread &&other)
Definition Thread.h:80
Declaration of memory manager for allocating small pieces of memory.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
Definition GML.h:110