-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThread.cpp
More file actions
40 lines (32 loc) · 750 Bytes
/
Thread.cpp
File metadata and controls
40 lines (32 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Thread.cpp
*
* Created on: Dec 27, 2012
* Author: jeff
*/
#include "Thread.h"
Thread::Thread() :
killThread(false),
thread(NULL) {}
Thread::~Thread() {}
void Thread::join() {
pthread_join(thread, NULL);
}
void Thread::start() {
pthread_create(&thread, NULL, pthread_entry, this);
}
void Thread::stop() {
killThread = true;
}
void* Thread::pthread_entry(void* arg) {
Thread* threadedObject = (Thread*)arg;
return threadedObject->run();
}
void Thread::setPriority(int prio) {
//Get us on a higher priority...
int policy;
struct sched_param params;
pthread_getschedparam(thread, &policy, ¶ms);
params.sched_priority = prio;
pthread_setschedparam(thread, policy, ¶ms);
}