MAK Data Logger API Documentation for DIS
threadSafe.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 
11 #ifndef threadSafe_H_
12 #define threadSafe_H_
13 #include "lgrUtil.h"
14 
15 #include <vlutil/vlMutex.h>
16 #include <vlutil/vlScopedLock.h>
17 
18 namespace MAKLogger
19 {
20 
43 
45  {
46  public:
48  typedef void (*LockFunction)(void*);
49 
53 
55  virtual ~DtScopedSequenceLock();
56 
57  protected:
58 
60  DtScopedSequenceLock(void* object,LockFunction lockCB,LockFunction unlockCB);
61 
63  LockFunction myLockCallback;
64 
66  LockFunction myUnlockCallback;
67 
69  void* myObject;
70  };
71 
72 
99 
100  template <typename T>
102  {
103 #ifndef __solaris__
104  protected:
105 #else
106  public:
107 #endif
108  class LockedProxy;
109  class ConstLockedProxy;
110  friend class SequenceLockImpl;
111  public:
112 
113  DtThreadSafe(const T& value);
114 
116  operator T() const;
117 
121 
125 
128 
130  DtThreadSafe<T>& operator =(const T& orig);
131 
137 #ifndef __solaris__
138  protected:
139 #else
140  public:
141 #endif
142 
147  {
148  public:
150  LockedProxy(T& value,DtMutex& mutex);
152  LockedProxy(const LockedProxy& orig);
154  ~LockedProxy();
155 
159  T* operator->();
160 
161  protected:
163  DtMutex& myMutex;
164  DtScopedLock myLock;
165  };
166 
171  {
172  public:
174  ConstLockedProxy(const T& value,DtMutex& mutex);
176  ConstLockedProxy(const ConstLockedProxy& orig);
179 
183  const T* operator->();
184 
185  protected:
186  const T* myValue;
187  DtMutex& myMutex;
188  DtScopedLock myLock;
189  };
190 
191 
196  {
197  public:
200 
202  virtual ~SequenceLockImpl();
205  static void lock(void* object);
206 
208  static void unlock(void* object);
209  };
210 
212  void lockObject();
213 
215  void unlockObject();
216 
221  DtScopedLock* myExternalLock;
222 
224  DtMutex myLockMutex;
225 
227  mutable DtMutex myMutex;
228  };
229 
230 #define threadSafe_inl_
231 #include "threadSafe.inl"
232 #undef threadSafe_inl_
233 
234 }
235 
236 #endif

Document ID: Generated on Mon Jan 19 08:20:14 EST 2015 from SVN revision 149581
Copyright © 2005-2012 VT MÄK. All Rights Reserved (www.mak.com)