PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/xbmc/visualizations/XBMCProjectM/libprojectM/SectionLock.h

http://github.com/xbmc/xbmc
C++ Header | 27 lines | 23 code | 4 blank | 0 comment | 0 complexity | 3825df63b10a54892d7869aa396a47c8 MD5 | raw file
 1
 2#ifndef SECTION_LOCK_H__
 3#define SECTION_LOCK_H__
 4
 5#include <pthread.h>
 6#include <assert.h>
 7
 8class CSectionLock
 9{
10  pthread_mutex_t* m_lock;
11  public:
12    CSectionLock(pthread_mutex_t* lock) : m_lock(lock)
13    {
14#ifdef _USE_THREADS
15      assert(lock);
16      pthread_mutex_lock(&m_lock);
17#endif
18    }
19    ~CSectionLock()
20    {
21#ifdef _USE_THREADS
22      pthread_mutex_unlock(&m_lock);
23#endif
24    }
25};
26
27#endif // SECTION_LOCK_H__