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
FMEThread.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Barrier.h>
35#include <ogdf/basic/Thread.h>
39
40namespace ogdf {
41namespace fast_multipole_embedder {
42
43class FMEThreadPool;
44
49class FMETask {
50public:
51 virtual ~FMETask() { }
52
53 virtual void doWork() = 0;
54};
55
59template<typename FuncInvokerType>
61public:
64
66 void doWork() override { funcInvoker(); }
67
68private:
71};
72
76class FMEThread /*: public Thread*/
77{
78public:
81
83 inline uint32_t threadNr() const { return m_threadNr; }
84
86 inline uint32_t numThreads() const { return m_numThreads; }
87
89 inline bool isMainThread() const { return m_threadNr == 0; }
90
92 inline FMEThreadPool* threadPool() const { return m_pThreadPool; }
93
95 void sync();
96
97#ifdef OGDF_HAS_LINUX_CPU_MACROS
98 void unixSetAffinity();
99#else
101#endif
102
104 void operator()() {
106 m_pTask->doWork();
107 delete m_pTask;
108 m_pTask = nullptr;
109 }
110
113
114private:
116
118
120
122
123 FMEThread(const FMEThread&); // = delete
124 FMEThread& operator=(const FMEThread&); // = delete
125};
126
128public:
130
132
134 inline uint32_t numThreads() const { return m_numThreads; }
135
137 inline FMEThread* thread(uint32_t threadNr) const { return m_pThreads[threadNr]; }
138
140 inline Barrier* syncBarrier() const { return m_pSyncBarrier; }
141
144
145 template<typename KernelType, typename ArgType1>
154
155private:
156 void allocate();
157
159
161
163
165};
166
167}
168}
Declaration of class ArrayGraph.
Implementation of a thread barrier.
Definition of utility functions for FME layout.
Declaration of class LinearQuadtree.
Declaration of Thread class representing threads.
Representation of a barrier.
Definition Barrier.h:49
Class used to invoke a functor or function inside a thread.
Definition FMEThread.h:60
void doWork() override
overrides the task doWork() method and invokes the function or functor
Definition FMEThread.h:66
FMEFuncInvokerTask(FuncInvokerType f)
constructor with an invoker
Definition FMEThread.h:63
The thread task class used only as an interface.
Definition FMEThread.h:49
The fast multipole embedder work thread class.
Definition FMEThread.h:77
FMEThreadPool * threadPool() const
returns the ThreadPool this thread belongs to
Definition FMEThread.h:92
bool isMainThread() const
returns true if this is the main thread ( the main thread is always the first thread )
Definition FMEThread.h:89
uint32_t numThreads() const
returns the total number of threads in the pool
Definition FMEThread.h:86
void operator()()
the main work function
Definition FMEThread.h:104
void setTask(FMETask *pTask)
sets the actual task
Definition FMEThread.h:112
uint32_t threadNr() const
returns the index of the thread ( 0.. numThreads()-1 )
Definition FMEThread.h:83
FMEThread(FMEThreadPool *pThreadPool, uint32_t threadNr)
construtor
FMEThread & operator=(const FMEThread &)
Barrier * syncBarrier() const
returns the barrier instance used to sync the threads during execution
Definition FMEThread.h:140
void runThreads()
runs one iteration. This call blocks the main thread
uint32_t numThreads() const
returns the number of threads in this pool
Definition FMEThread.h:134
FMEThread * thread(uint32_t threadNr) const
returns the threadNr-th thread
Definition FMEThread.h:137
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.