threads.h
Go to the documentation of this file.
1 //==================================================================
2 // File : threads.h
3 // Author : rsagalyn
4 // Date : Aug 25, 2013
5 // Description : Abstract thread encapsulation class
6 //==================================================================
7 #ifndef THREADS_H
8 #define THREADS_H
9 
10 #include <cstring>
11 #include <iostream>
12 #include <pthread.h>
13 #include "tsp.h"
14 
15 #pragma comment(lib,"pthreadVC2.lib")
16 
17 using namespace std;
18 
19 // Abstract Thread class
20 class Thread
21 {
22 private:
23  // Internally track thread ids
24  pthread_t _id;
25 
26  // Serves as global function for pthraed_create
27  // Internally calls member function run
28  static void *exec(void *thr);
29 
30  // Prevent copying
31  Thread(const Thread& arg);
32 
33  // Prevent assignment
34  Thread& operator=(const Thread& rhs);
35 
36 protected:
37  // Pure virtual function, to implement with code thread should run
38  virtual void run() = 0;
39 
40 public:
41  // Constructor
42  Thread() {
43  mytsp = NULL;
44  //_id = 0;
45  my_id = start_node = -1;
46  };
47 
48  // Destructor
49  virtual ~Thread() {};
50 
51  // Starts the internal thread
52  void start();
53 
54  // Wait for internal thread to exit
55  void join();
56 
57  // Get thread id of internal thread
58  //long get_tid() {return (long)_id;}
59 
60  // Index of node to start touring at
62 
63  // Pointer to TSP object
65 
66  // Assigned ID (for tracking purposes)
67  int my_id;
68 };
69 
70 
71 #endif
ROSCPP_DECL void start()
pthread_t _id
Definition: threads.h:24
virtual ~Thread()
Definition: threads.h:49
int my_id
Definition: threads.h:67
TSP * mytsp
Definition: threads.h:64
int start_node
Definition: threads.h:61
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Definition: tsp.h:54
Definition: threads.h:20
Thread()
Definition: threads.h:42


co_scan
Author(s):
autogenerated on Mon Feb 28 2022 23:00:54