Mercurial > hg > svcore
comparison base/Thread.cpp @ 109:61a2ac1241b3
* Make a single base Thread class for RT and non-RT threads
* Pull ResizeableBitmap out from the MatrixFile's ColumnBitmap
* Reorder SpectrogramLayer::paint somewhat so as to improve cache hit ratio
in the FFT file cache
author | Chris Cannam |
---|---|
date | Mon, 08 May 2006 16:44:47 +0000 |
parents | |
children | 85bf384db35f |
comparison
equal
deleted
inserted
replaced
108:0c19e50bad7c | 109:61a2ac1241b3 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #include "Thread.h" | |
17 | |
18 #ifndef _WIN32 | |
19 #include <pthread.h> | |
20 #endif | |
21 | |
22 Thread::Thread(Type type, QObject *parent) : | |
23 QThread(parent), | |
24 m_type(type) | |
25 { | |
26 setStackSize(512 * 1024); | |
27 } | |
28 | |
29 void | |
30 Thread::start() | |
31 { | |
32 QThread::start(); | |
33 | |
34 #ifndef _WIN32 | |
35 struct sched_param param; | |
36 ::memset(¶m, 0, sizeof(param)); | |
37 | |
38 if (m_type == RTThread) { | |
39 | |
40 param.sched_priority = 5; | |
41 | |
42 if (::pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m)) { | |
43 ::perror("INFO: pthread_setschedparam to SCHED_FIFO failed"); | |
44 } | |
45 | |
46 } else { | |
47 | |
48 if (::pthread_setschedparam(pthread_self(), SCHED_OTHER, ¶m)) { | |
49 ::perror("WARNING: pthread_setschedparam to SCHED_OTHER failed"); | |
50 } | |
51 } | |
52 | |
53 #endif | |
54 } | |
55 |