votca 2024.2-dev
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef VOTCA_TOOLS_THREAD_H
19#define VOTCA_TOOLS_THREAD_H
20
21// Standard includes
22#include <pthread.h>
23
24namespace votca {
25namespace tools {
26
35class Thread {
36 public:
38 virtual ~Thread();
39
45 void Start();
46
50 void WaitDone();
51
57 bool IsFinished() const;
58
59 protected:
67 virtual void Run(void) = 0;
68 friend void *runwrapper(void *arg);
69
70 private:
71 pthread_attr_t attr_;
72 pthread_t thread_;
74};
75} // namespace tools
76} // namespace votca
77
78#endif // VOTCA_TOOLS_THREAD_H
Framework for threaded execution.
Definition thread.h:35
pthread_t thread_
Definition thread.h:72
friend void * runwrapper(void *arg)
Definition thread.cc:31
virtual void Run(void)=0
Run() executes the actual code.
pthread_attr_t attr_
Definition thread.h:71
void WaitDone()
WaitDone() will not exit until thread ends computation.
Definition thread.cc:66
void Start()
Starts and runs a thread.
Definition thread.cc:42
bool IsFinished() const
Checks to see if the thread is done.
Definition thread.cc:77
base class for all analysis tools
Definition basebead.h:33