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

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

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

revision 2426 by nagata, Sun Jan 27 09:44:30 2008 UTC revision 2427 by persson, Sat Mar 2 07:03:04 2013 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, 2006 Christian Schoenebeck                        *   *   Copyright (C) 2005 - 2013 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 88  class Mutex { Line 88  class Mutex {
88           * Lock() call, one of them will be awaken.           * Lock() call, one of them will be awaken.
89           */           */
90          void Unlock();          void Unlock();
91            
92      protected:      protected:
93      #if defined(WIN32)      #if defined(WIN32)
94      HANDLE hMutex;          HANDLE hMutex;
95      #else      #else
96          pthread_mutex_t     __posix_mutex;          pthread_mutex_t     __posix_mutex;
97          pthread_mutexattr_t __posix_mutexattr;          pthread_mutexattr_t __posix_mutexattr;
98      #endif      #endif
99  };  };
100    
101    // Lock guard for exception safe locking
102    class LockGuard {
103    public:
104        LockGuard(Mutex& m) : pm(m) {
105            m.Lock();
106        }
107        ~LockGuard() {
108            pm.Unlock();
109        }
110    private:
111        Mutex& pm;
112    };
113    
114  } // namespace LinuxSampler  } // namespace LinuxSampler
115    
116  #endif // __MUTEX_H__  #endif // __MUTEX_H__

Legend:
Removed from v.2426  
changed lines
  Added in v.2427

  ViewVC Help
Powered by ViewVC