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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 57 by schoenebeck, Sun May 2 17:45:43 2004 UTC revision 1424 by schoenebeck, Sun Oct 14 22:00:17 2007 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   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  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 20  Line 21 
21   *   MA  02111-1307  USA                                                   *   *   MA  02111-1307  USA                                                   *
22   ***************************************************************************/   ***************************************************************************/
23    
24  #ifndef __THREAD_H__  #ifndef __LS_THREAD_H__
25  #define __THREAD_H__  #define __LS_THREAD_H__
26    
27  #include <iostream>  #include <iostream>
28  #include <stdio.h>  #include <stdio.h>
# Line 32  Line 33 
33  #include <pthread.h>  #include <pthread.h>
34  #include <errno.h>  #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.  /// Abstract base class for classes that need to run in an own thread.
41  class Thread {  class Thread {
42      public:      public:
43          Thread(bool RealTime, int PriorityMax, int PriorityDelta);          Thread(bool LockMemory, bool RealTime, int PriorityMax, int PriorityDelta);
44          virtual ~Thread();          virtual ~Thread();
45          virtual int  StartThread();          virtual int  StartThread();
46          virtual int  StopThread();          virtual int  StopThread();
47          virtual int  SignalStartThread();          virtual int  SignalStartThread();
48          virtual int  SignalStopThread();          virtual int  SignalStopThread();
49          virtual bool IsRunning() { return Running; }          virtual bool IsRunning();
50          virtual int  SetSchedulingPriority(); //FIXME: should be private          virtual int  SetSchedulingPriority(); //FIXME: should be private
51            virtual int  LockMemory();            //FIXME: should be private
52          virtual void EnableDestructor();      //FIXME: should be private          virtual void EnableDestructor();      //FIXME: should be private
53          virtual int  Destructor();            //FIXME: should be private          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          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:      private:
56            pthread_attr_t  __thread_attr;
57          pthread_t       __thread_id;          pthread_t       __thread_id;
58          pthread_key_t   __thread_destructor_key;          pthread_key_t   __thread_destructor_key;
59          pthread_mutex_t __thread_state_mutex;          Condition       RunningCondition;
         pthread_cond_t  __thread_start_condition;  
         pthread_cond_t  __thread_exit_condition;  
60          int             PriorityMax;          int             PriorityMax;
61          int             PriorityDelta;          int             PriorityDelta;
         bool            Running;  
62          bool            isRealTime;          bool            isRealTime;
63            bool            bLockedMemory;
64  };  };
65    
66  // Callback functions for the POSIX thread API  } // namespace LinuxSampler
 void* __pthread_launcher(void* thread);  
 void  __pthread_destructor(void* thread);  
67    
68  #endif // __THREAD_H__  #endif // __LS_THREAD_H__

Legend:
Removed from v.57  
changed lines
  Added in v.1424

  ViewVC Help
Powered by ViewVC