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
31 #define ThreadAPI(proc, arg) DWORD WINAPI proc (LPVOID arg)
33 typedef LPTHREAD_START_ROUTINE ThreadProcPtr
;
34 typedef HANDLE ThreadHandle
;
39 #define ThreadAPI(proc, arg) void * proc (void * arg)
41 typedef void * ( * ThreadProcPtr
) (void * ptr
);
42 typedef pthread_t ThreadHandle
;
46 //___________________________________________________________________
48 \brief cross platform threads support
50 Based on pthread on linux and mac and
51 Windows native threads on Windows
56 enum { kNormalPriority
=0 };
59 virtual ~TThreads () { quit (); }
61 virtual void run() = 0;
63 bool start (int priority
= kNormalPriority
);
64 bool isRunning () const { return fRunning
; }
67 void running (bool state
) { fRunning
= state
; }
70 int SetPriority (int priority
);
73 ThreadHandle fThread
; // the thread handler