Mobile API Reference  MicroStrategy 2019
BinaryDataLock.h
Go to the documentation of this file.
1 //
2 // BinaryDataLock.h
3 // ReportServiceCore
4 //
5 // Created by Yang Zhuo on 10/18/13.
6 // Copyright (c) 2013 MicroStrategy, Inc. All rights reserved.
7 //
8 
9 #include<pthread.h>
10 //#include "GUID.h"
11 #include<map>
12 #include "Base/Base/GUID.h"
13 
14 using MBase::operator <;
15 using namespace std;
16 
17 #ifndef ReportServiceCore_BinaryDataLock_h
18 #define ReportServiceCore_BinaryDataLock_h
19 /*
20 bool operator < (const GUID &iID1, const GUID &iID2)
21 {
22  return MBase::CompareGUID(iID1, iID2);
23 }*/
24 
25 class BinaryDataLock;
26 
27 class SmartLock
28 {
29 public:
30  SmartLock(BinaryDataLock *ipBinaryLock, GUID &iGUID, pthread_mutex_t * ipMutex);
31  SmartLock(BinaryDataLock *ipBinaryLock, void *objectPoint);
32  SmartLock();
33  ~SmartLock();
34  void lock(BinaryDataLock *ipBinaryLock, void *objectPoint);
35 private:
36  BinaryDataLock *mpBinaryLock;
37  pthread_mutex_t *mpMutex;
38  GUID mGUID;
39 };
40 
42 {
43 public:
44  static BinaryDataLock * getInstance();
45  pthread_mutex_t *getDocumentLock(GUID &lID);
46  GUID getObjectGUID(void *objectPoint);
47 private:
49  ~BinaryDataLock();
50  static BinaryDataLock *mpInstance;
51  map<GUID, pthread_mutex_t *> mLockMap;
52  map<GUID, int> mLockUseTime;
53  map<GUID, int> mLockRefCnt;
54  int timetick;
55  pthread_mutex_t *mMapProtectLock;
56 
57  typedef map<void *, GUID> ObjectGUIDMap;
58  ObjectGUIDMap mObjectGUIDMap;
59 
60 friend class SmartLock;
61 };
62 
63 #endif
Definition: LessThanGUID.h:49
Definition: BinaryDataLock.h:41
Definition: BinaryDataLock.h:27
Definition: Base/Base/GUID.h:32