Scopira  20080306
mutex_qtthreads.h
1 
2 /*
3  * Copyright (c) 2009 National Research Council
4  *
5  * All rights reserved.
6  *
7  * This material is confidential and proprietary information of
8  * National Research Council Canada ("Confidential Information").
9  * This Confidential Information may only be used and reproduced
10  * in accordance with the terms of the license agreement.
11  *
12  */
13 
14 #ifndef __INCLUDED_SCOPIRA_TOOL_MUTEX_QTTHREADS_H__
15 #define __INCLUDED_SCOPIRA_TOOL_MUTEX_QTTHREADS_H__
16 
17 #include <QMutex>
18 
19 #include <scopira/tool/platform.h>
20 #include <scopira/tool/export.h>
21 
22 namespace scopira
23 {
24  namespace tool
25  {
26  class mutex;
27  class locker;
28  }
29 }
30 
39 {
40  protected:
41  QMutex dm_mut;
42 
43  public:
45  SCOPIRA_EXPORT mutex(void);
46  SCOPIRA_EXPORT ~mutex(void);
47 
53  SCOPIRA_EXPORT void lock(void) { dm_mut.lock(); }
54 
61  SCOPIRA_EXPORT void unlock(void) { dm_mut.unlock(); }
62 
73  SCOPIRA_EXPORT bool try_lock(void) { return dm_mut.tryLock(); }
74 
79  SCOPIRA_EXPORT inline QMutex * get_os_mutex(void) { return &dm_mut; }
80 };
81 
91 {
92  private:
93  mutex &dm_mut;
94  public:
99  locker(mutex &mut) : dm_mut(mut) { dm_mut.lock(); }
104  ~locker() { dm_mut.unlock(); }
105 };
106 
107 #endif
108 
locker(mutex &mut)
Definition: mutex_qtthreads.h:99
Definition: mutex_pthreads.h:40
Definition: archiveflow.h:20
QMutex * get_os_mutex(void)
Definition: mutex_qtthreads.h:79
void lock(void)
Definition: mutex_qtthreads.h:53
void unlock(void)
Definition: mutex_qtthreads.h:61
Definition: mutex_pthreads.h:92
~locker()
Definition: mutex_qtthreads.h:104
bool try_lock(void)
Definition: mutex_qtthreads.h:73