Mobile API Reference  MicroStrategy 2019
SharedMemory.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : SharedMemory.h
3 // AUTHOR : Michael Yan
4 // CREATION : 3/15/2007
5 // Copyright (C) MicroStrategy Incorporated 2007
6 // All Rights Reserved
7 //==============================================================================================
8 #ifndef MMultiProcess_SharedMemory_h
9 #define MMultiProcess_SharedMemory_h
10 
11 #include "SharedMemoryIncl.h"
12 #include "Base/Defines/StrongPtr.h"
14 
15 #if defined(WIN32) || defined(WIN64)
16 #include "PDCHeader/PDCtchar.h"
17 #define MAX_INT_STR 65
18 #pragma warning(disable:4996) // '_ui64tow': This function or variable may be unsafe. Consider using _ui64tow_s instead.
19 #endif
20 
21 namespace MMultiProcess
22 {
23  typedef unsigned Int32 shm_size_t;
24 
25  // Shared memory identifier, platform dependant
27  {
28  public:
29  SharedMemoryID(int id) : mSharedMemoryID(id) {}
30 
31  int GetID() { return mSharedMemoryID; }
32 
33 #if defined(WIN32) || defined(WIN64)
34  void GetID(TCHAR *ipIdStr)
35  {
36  //Pass me at least TCHAR ipIdStr[65]
37  if(ipIdStr != NULL)
38  _ui64tot(mSharedMemoryID,ipIdStr,10);
39  }
40 #endif
41 
42  private:
43  int mSharedMemoryID;
44  };
45 
60  {
61  public:
62 
65  virtual ~SharedMemory() throw() {}
66 
69  virtual shm_size_t GetTotalSize() = 0;
70 
78  virtual void* GetWriteBlock(shm_size_t iReqestSize, shm_size_t& orAcquiredSize, Int64 iTimeOutInMillisecond=-1) = 0;
79 
87  virtual void* GetReadBlock(shm_size_t& orBlockSize, Int64 iTimeOutInMillisecond=-1) = 0;
88 
89  // Return True if there is available read memory; False if time out.
90  virtual bool WaitOnReadMemory(Int64 iTimeOutInMillisecond=-1) = 0;
91 
95  virtual void ReleaseBlock(void* ipStartAddr) = 0;
96 
99  virtual void* GetHandle() = 0;
100 
101  virtual void Delete() = 0;
102  };
103 
106  {
110  };
111 
113 
121 
128  //DLL_SHAREDMEMORY_EXIM SharedMemory* CreateSharedMemory(const SharedMemoryID& iSharedMemId);
129 
130  // Instances of this class may be thrown from Event methods.
132  {
133  };
134 }
135 
136 #endif // MMultiProcess_SharedMemory_h
int GetID()
Definition: SharedMemory.h:31
DLL_SHAREDMEMORY_EXIM SharedMemory * CreateSharedMemory(const SharedMemoryID &iSharedMemId, SHM_ACCESS_MODE iMode=SHM_DUMMY)
#define DLL_SHAREDMEMORY_EXIM
Definition: SharedMemoryIncl.h:19
#define Int64
Definition: BasicTypes.h:36
Definition: SharedMemory.h:108
Definition: SharedMemory.h:131
unsigned Int32 shm_size_t
Definition: SharedMemory.h:23
#define Int32
Definition: BasicTypes.h:20
Definition: SharedMemory.h:109
Definition: Message.h:32
Definition: SharedMemory.h:107
SHM_ACCESS_MODE
Shared memory is created in either read or write mode.
Definition: SharedMemory.h:105
Definition: StrongPtr.h:50
virtual ~SharedMemory()
Definition: SharedMemory.h:65
SharedMemoryID(int id)
Definition: SharedMemory.h:29
WCHAR TCHAR
Definition: PDCwtypes.h:352
Definition: SharedMemory.h:59
#define _ui64tot
Definition: PDCtchar.h:51
Definition: SharedMemory.h:21
#define NULL
Definition: Null.h:10
Definition: SharedMemory.h:26
MBase::StrongPtr< SharedMemory, MBase::DeleteOperatorGeneric< SharedMemory > > SharedMemoryPtr
Definition: SharedMemory.h:112