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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1212 - (hide annotations) (download) (as text)
Tue May 29 23:59:36 2007 UTC (16 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3391 byte(s)
* added highly experimental support for on-the-fly instrument editing
  within the sampler's process (by using instrument editor plugins),
  you'll notice the new "Registered instrument editors:" message on
  startup, the plugin path can be overridden at compile time with
  ./configure --enable-plugin-dir=/some/dir
* added a new LSCP command "EDIT INSTRUMENT <sampler-channel>" to spawn
  a matching instrument editor for the instrument on the given sampler
  channel (LSCP command syntax might be subject to change soon)
* config.h is not going to be installed along with liblinuxsampler's
  API header files anymore (not necessary anymore)
* take care of $(DESTDIR) when creating the instruments DB on 'make
  install' rule (needed for packaging and cross compilation)
* bumped version to 0.4.0.5cvs

1 schoenebeck 53 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5 schoenebeck 56 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 1212 * Copyright (C) 2005 - 2007 Christian Schoenebeck *
7 schoenebeck 53 * *
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 __THREAD_H__
25     #define __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 schoenebeck 1212 namespace LinuxSampler {
37    
38 schoenebeck 53 /// Abstract base class for classes that need to run in an own thread.
39     class Thread {
40     public:
41 schoenebeck 392 Thread(bool LockMemory, bool RealTime, int PriorityMax, int PriorityDelta);
42 schoenebeck 53 virtual ~Thread();
43     virtual int StartThread();
44     virtual int StopThread();
45 schoenebeck 57 virtual int SignalStartThread();
46 schoenebeck 53 virtual int SignalStopThread();
47 schoenebeck 1212 virtual bool IsRunning();
48 schoenebeck 53 virtual int SetSchedulingPriority(); //FIXME: should be private
49 schoenebeck 392 virtual int LockMemory(); //FIXME: should be private
50 schoenebeck 53 virtual void EnableDestructor(); //FIXME: should be private
51     virtual int Destructor(); //FIXME: should be private
52     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
53     private:
54     pthread_t __thread_id;
55     pthread_key_t __thread_destructor_key;
56     pthread_mutex_t __thread_state_mutex;
57 schoenebeck 57 pthread_cond_t __thread_start_condition;
58 schoenebeck 53 pthread_cond_t __thread_exit_condition;
59     int PriorityMax;
60     int PriorityDelta;
61     bool Running;
62     bool isRealTime;
63 schoenebeck 392 bool bLockedMemory;
64 schoenebeck 53 };
65    
66     // Callback functions for the POSIX thread API
67     void* __pthread_launcher(void* thread);
68     void __pthread_destructor(void* thread);
69    
70 schoenebeck 1212 } // namespace LinuxSampler
71    
72 schoenebeck 53 #endif // __THREAD_H__

  ViewVC Help
Powered by ViewVC