summaryrefslogtreecommitdiff
path: root/ace/Shared_Memory_MM.h
blob: 7852f0c976e734124808b9c7644866dc45e78272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* -*- C++ -*- */
// $Id$


// ============================================================================
//
// = LIBRARY
//    ace
// 
// = FILENAME
//    Shared_Memory_MM.h
//
// = AUTHOR
//    Doug Schmidt 
// 
// ============================================================================

#if !defined (ACE_SHARED_MALLOC_MM_H)
#define ACE_SHARED_MALLOC_MM_H

#include "ace/Shared_Memory.h"
#include "ace/Mem_Map.h"

class ACE_Export ACE_Shared_Memory_MM : public ACE_Shared_Memory
  // = TITLE
  //     Shared memory wrapper based on MMAP.
{
public:
  // = Initialization and termination methods.
  ACE_Shared_Memory_MM (void);
  ACE_Shared_Memory_MM (ACE_HANDLE handle, 
			int length = -1, 
			int prot = PROT_RDWR, 
			int share = MAP_PRIVATE, 
			char *addr = 0, 
			off_t pos = 0);
  ACE_Shared_Memory_MM (char file_name[], 
			int len = -1, 
			int flags = O_RDWR | O_CREAT,
			int mode = ACE_DEFAULT_FILE_PERMS, 
			int prot = PROT_RDWR, 
			int share = MAP_SHARED, 
			char *addr = 0, off_t pos = 0);

  int open (ACE_HANDLE handle, 
	    int length = -1, 
	    int prot = PROT_RDWR, 
	    int share = MAP_PRIVATE, 
	    char *addr = 0, 
	    off_t pos = 0);

  int open (char file_name[], 
	    int len = -1, 
	    int flags = O_RDWR | O_CREAT, 
	    int mode = ACE_DEFAULT_FILE_PERMS, 
	    int prot = PROT_RDWR, 
	    int share = MAP_SHARED, 
	    char *addr = 0, 
	    off_t pos = 0);

  virtual int close (void);
  // Close down the shared memory segment.

  virtual int remove (void);
  // Remove the shared memory segment and the underlying file.

  // = Allocation and deallocation methods.
  virtual void *malloc (size_t size = 0);
  // Create a new chuck of memory containing <size> bytes.

  virtual int free (void *p);
  // Free a chuck of memory allocated by <ACE_Shared_Memory_MM::malloc>.
  
  virtual int get_segment_size (void) const;
  // Return the size of the shared memory segment.
  
  virtual ACE_HANDLE get_id (void) const;
  // Return the ID of the shared memory segment (i.e., an ACE_HANDLE).

  void dump (void) const;
  // Dump the state of an object.

  ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

private:
   ACE_Mem_Map shared_memory_;
   // This version is implemented with memory-mapped files.
};

#if defined (__ACE_INLINE__)
#include "ace/Shared_Memory_MM.i"
#endif /* __ACE_INLINE__ */

#endif /* ACE_SHARED_MALLOC_MM_H */