044062a046e44e6bf1b48da19b4e913e55a8d5c3
3 Copyright (C) 2011 Grame
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
30 #include <sys/types.h>
36 //_____________________________________________________________________
37 static void * baseThreadProc (void * ptr
)
39 TThreads
* thread
= (TThreads
*)ptr
;
40 thread
->running (true);
42 thread
->running (false);
46 //_____________________________________________________________________
47 TThreads::TThreads () : fRunning(false), fThread(0) {}
49 //_____________________________________________________________________
50 int TThreads::SetPriority (int priority
)
53 struct sched_param param
;
55 param
.sched_priority
= priority
;
56 if (!pthread_setschedparam (fThread
, SCHED_OTHER
, ¶m
))
62 //_____________________________________________________________________
63 bool TThreads::start (int priority
)
65 int ret
= pthread_create(&fThread
, NULL
, baseThreadProc
, this);
67 SetPriority (priority
);
73 //_____________________________________________________________________
74 void TThreads::quit ()
78 pthread_cancel (fThread
);
79 pthread_join (fThread
, &threadRet
);