/[svn]/linuxsampler/trunk/src/common/Thread.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/common/Thread.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1424 - (show annotations) (download) (as text)
Sun Oct 14 22:00:17 2007 UTC (16 years, 5 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3197 byte(s)
* code cleanup:
- global.h now only covers global definitions that are needed for the C++
  API header files, all implementation internal global definitions are now
  in global_private.h
- atomic.h is not exposed to the C++ API anymore (replaced the references
  in SynchronizedConfig.h for this with local definitions)
- no need to include config.h anymore for using LS's API header files
- DB instruments classes are not exposed to the C++ API
- POSIX callback functions of Thread.h are hidden
- the (optional) gig Engine benchmark compiles again
- updated Doxyfile.in
- fixed warnings in API doc generation
* preparations for release 0.5.0

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2007 Christian Schoenebeck *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24 #ifndef __LS_THREAD_H__
25 #define __LS_THREAD_H__
26
27 #include <iostream>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <sched.h>
31 #include <sys/mman.h>
32 #include <memory.h>
33 #include <pthread.h>
34 #include <errno.h>
35
36 #include "Condition.h"
37
38 namespace LinuxSampler {
39
40 /// Abstract base class for classes that need to run in an own thread.
41 class Thread {
42 public:
43 Thread(bool LockMemory, bool RealTime, int PriorityMax, int PriorityDelta);
44 virtual ~Thread();
45 virtual int StartThread();
46 virtual int StopThread();
47 virtual int SignalStartThread();
48 virtual int SignalStopThread();
49 virtual bool IsRunning();
50 virtual int SetSchedulingPriority(); //FIXME: should be private
51 virtual int LockMemory(); //FIXME: should be private
52 virtual void EnableDestructor(); //FIXME: should be private
53 virtual int Destructor(); //FIXME: should be private
54 virtual int Main() = 0; ///< This method needs to be implemented by the descendant and is the entry point for the new thread. FIXME: should be protected
55 private:
56 pthread_attr_t __thread_attr;
57 pthread_t __thread_id;
58 pthread_key_t __thread_destructor_key;
59 Condition RunningCondition;
60 int PriorityMax;
61 int PriorityDelta;
62 bool isRealTime;
63 bool bLockedMemory;
64 };
65
66 } // namespace LinuxSampler
67
68 #endif // __LS_THREAD_H__

  ViewVC Help
Powered by ViewVC