Mercurial > hg > svcore
annotate base/NonRTThread.cpp @ 97:22494cc28c9f
* Reduce number of allocations and deallocations by keeping a spare buffer
around (we were generally deallocating and then immediately allocating again,
so it's much better not to have to bother as very large allocations can tie
up the system)
author | Chris Cannam |
---|---|
date | Thu, 04 May 2006 20:17:28 +0000 |
parents | 1aebdc68ec6d |
children | 9a44ccae165c |
rev | line source |
---|---|
Chris@96 | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
Chris@96 | 2 |
Chris@96 | 3 /* |
Chris@96 | 4 Sonic Visualiser |
Chris@96 | 5 An audio file viewer and annotation editor. |
Chris@96 | 6 Centre for Digital Music, Queen Mary, University of London. |
Chris@96 | 7 This file copyright 2006 Chris Cannam. |
Chris@96 | 8 |
Chris@96 | 9 This program is free software; you can redistribute it and/or |
Chris@96 | 10 modify it under the terms of the GNU General Public License as |
Chris@96 | 11 published by the Free Software Foundation; either version 2 of the |
Chris@96 | 12 License, or (at your option) any later version. See the file |
Chris@96 | 13 COPYING included with this distribution for more information. |
Chris@96 | 14 */ |
Chris@96 | 15 |
Chris@96 | 16 #include "NonRTThread.h" |
Chris@96 | 17 |
Chris@96 | 18 #include <pthread.h> |
Chris@96 | 19 |
Chris@96 | 20 NonRTThread::NonRTThread(QObject *parent) : |
Chris@96 | 21 QThread(parent) |
Chris@96 | 22 { |
Chris@96 | 23 setStackSize(512 * 1024); |
Chris@96 | 24 } |
Chris@96 | 25 |
Chris@96 | 26 void |
Chris@96 | 27 NonRTThread::start() |
Chris@96 | 28 { |
Chris@96 | 29 QThread::start(); |
Chris@96 | 30 |
Chris@96 | 31 #ifndef Q_WS_WIN32 |
Chris@96 | 32 struct sched_param param; |
Chris@96 | 33 ::memset(¶m, 0, sizeof(param)); |
Chris@96 | 34 |
Chris@96 | 35 if (::pthread_setschedparam(pthread_self(), SCHED_OTHER, ¶m)) { |
Chris@96 | 36 ::perror("pthread_setschedparam to SCHED_OTHER failed"); |
Chris@96 | 37 } |
Chris@96 | 38 #endif |
Chris@96 | 39 } |
Chris@96 | 40 |