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

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

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

revision 56 by schoenebeck, Tue Apr 27 09:21:58 2004 UTC revision 1231 by schoenebeck, Mon Jun 11 10:06:52 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 25  Line 26 
26    
27  #include "Mutex.h"  #include "Mutex.h"
28    
29    namespace LinuxSampler {
30    
31  /**  /**
32   * Thread safe boolean condition.   * Thread safe boolean condition.
33   *   *
# Line 43  class Condition : public Mutex { Line 46  class Condition : public Mutex {
46          /**          /**
47           * Destructor           * Destructor
48           */           */
49          ~Condition();          virtual ~Condition();
50    
51          /**          /**
52           * Blocks the calling thread if current condition equals           * Blocks the calling thread if current condition equals
# Line 53  class Condition : public Mutex { Line 56  class Condition : public Mutex {
56           * critical section and has to explicitly call Unlock() right after           * critical section and has to explicitly call Unlock() right after
57           * it left it's critcal section.           * it left it's critcal section.
58           *           *
59             * @e Note: If you don't provide a timeout value or if you provide a
60             * timeout value of exactly 0s and 0ns, then this call will block
61             * without any timeout!
62             *
63           * @param bCondition         - block in case of this condition           * @param bCondition         - block in case of this condition
64           * @param TimeoutSeconds     - optional: max. wait time in seconds           * @param TimeoutSeconds     - optional: max. wait time in seconds
65           *                             (default: 0s)           *                             (default: 0s)
# Line 67  class Condition : public Mutex { Line 74  class Condition : public Mutex {
74           * Condition object, so only use this call if you don't need to           * Condition object, so only use this call if you don't need to
75           * enter a thread critical section, otherwise use WaitIf() instead!           * enter a thread critical section, otherwise use WaitIf() instead!
76           *           *
77             * @e Note: If you don't provide a timeout value or if you provide a
78             * timeout value of exactly 0s and 0ns, then this call will block
79             * without any timeout!
80             *
81           * @param bCondition         - block in case of this condition           * @param bCondition         - block in case of this condition
82           * @param TimeoutSeconds     - optional: max. wait time in seconds           * @param TimeoutSeconds     - optional: max. wait time in seconds
83           *                             (default: 0s)           *                             (default: 0s)
# Line 80  class Condition : public Mutex { Line 91  class Condition : public Mutex {
91          /**          /**
92           * Set Condition object to \a bCondition. Upon change of the           * Set Condition object to \a bCondition. Upon change of the
93           * condition, other threads waiting for \a bCondition will be           * condition, other threads waiting for \a bCondition will be
94           * awakened.           * awakened. (Note the condition will not be locked for the calling
95             * thread after this method returns!)
96           *           *
97           * @param bCondition - new condition           * @param bCondition - new condition
98           */           */
99          void Set(bool bCondition);          void Set(bool bCondition);
100    
101            /**
102             * Returns the current boolean state of this condition object.
103             * @e Caution: this method is not thread safe! If you need to use
104             * the condition state in a thread critical context you must call
105             * @c Lock() and @c Unlock() respectively by yourself!
106             */
107            bool GetUnsafe();
108    
109      protected:      protected:
110          pthread_cond_t __posix_true_condition;          pthread_cond_t __posix_true_condition;
111          pthread_cond_t __posix_false_condition;          pthread_cond_t __posix_false_condition;
112          bool bCondition;          bool bCondition;
113  };  };
114    
115    } // namespace LinuxSampler
116    
117  #endif // __CONDITION_H__  #endif // __CONDITION_H__

Legend:
Removed from v.56  
changed lines
  Added in v.1231

  ViewVC Help
Powered by ViewVC