/[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 3289 by persson, Sat Feb 18 13:51:38 2012 UTC revision 3290 by schoenebeck, Fri Jun 23 12:24:58 2017 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 - 2012 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2017 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 43  class ConditionInternal; Line 43  class ConditionInternal;
43   */   */
44  class Condition : public Mutex {  class Condition : public Mutex {
45      public:      public:
46          /**          /** @brief Constructor
47           * Constructor           *
48             * Creates a new thread safe condition variable.
49             *
50             * Note that the default bahavior of the underlying mutex is
51             * @c NON_RECURSIVE by default, because in general if your design
52             * requires the Condition object's lock state to be recursive instead,
53             * then most probably this may result in dead locks or even undefined
54             * behavior, because the underlying OS API for conditions may not be
55             * compatible with recursive mutexes!
56           *           *
57           * @param bInitialCondition - optional: starting condition           * @param bInitialCondition - optional: starting condition
58           *                            (default = false)           *                            (default = false)
59             * @param mutexType - optional: fundamental behavior of underlying mutex
60             *                    (default: @c NON_RECURSIVE)
61           */           */
62          Condition(bool bInitialCondition = false);          Condition(bool bInitialCondition = false, Mutex::type_t mutexType = Mutex::NON_RECURSIVE);
63    
64          /**          /**
65           * Destructor           * Destructor
# Line 97  class Condition : public Mutex { Line 107  class Condition : public Mutex {
107          int WaitAndUnlockIf(bool bCondition, long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L);          int WaitAndUnlockIf(bool bCondition, long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L);
108    
109          /**          /**
110             * You should use this method instead of WaitIf() in case the calling
111             * thread already owns the Condition object's underlying mutex lock by
112             * previously calling Lock() before. Essentially the only difference to
113             * WaitIf() is that PreLockedWaitIf() does not call Lock() by itself.
114             */
115            int PreLockedWaitIf(bool bCondition, long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L);
116    
117            /**
118             * You should use this method instead of WaitAndUnlockIf() in case the
119             * calling thread already owns the Condition object's underlying mutex
120             * lock by previously calling Lock() before. Essentially the only
121             * difference to WaitAndUnlockIf() is that PreLockedWaitAndUnlockIf()
122             * does not call Lock() by itself.
123             */
124            int PreLockedWaitAndUnlockIf(bool bCondition, long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L);
125    
126            /**
127           * Set Condition object to \a bCondition. Upon change of the           * Set Condition object to \a bCondition. Upon change of the
128           * condition, other threads waiting for \a bCondition will be           * condition, other threads waiting for \a bCondition will be
129           * awakened. (Note the condition will not be locked for the calling           * awakened. (Note the condition will not be locked for the calling
# Line 107  class Condition : public Mutex { Line 134  class Condition : public Mutex {
134          void Set(bool bCondition);          void Set(bool bCondition);
135    
136          /**          /**
137             * You should use this method instead of Set() in case the calling
138             * thread already owns the Condition object's underlying mutex lock by
139             * previously calling Lock() before. Essentially the only difference to
140             * Set() is that PreLockedSet() does not call Lock() by itself.
141             */
142            void PreLockedSet(bool bCondition);
143    
144            /**
145           * Returns the current boolean state of this condition object. This           * Returns the current boolean state of this condition object. This
146           * method never blocks, it returns immediately and doesn't use any           * method never blocks, it returns immediately and doesn't use any
147           * system calls.           * system calls.
# Line 127  class Condition : public Mutex { Line 162  class Condition : public Mutex {
162  #endif  #endif
163    
164      protected:      protected:
165            int WaitIfInternal(bool bLock, bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds);
166            void SetInternal(bool bLock, bool bCondition);
167    
168      #if defined(WIN32)      #if defined(WIN32)
169          friend class ConditionInternal;          friend class ConditionInternal;
170          struct win32thread_cond_t {          struct win32thread_cond_t {

Legend:
Removed from v.3289  
changed lines
  Added in v.3290

  ViewVC Help
Powered by ViewVC