aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llplugin/llpluginsharedmemory.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llplugin/llpluginsharedmemory.h')
-rwxr-xr-xlinden/indra/llplugin/llpluginsharedmemory.h132
1 files changed, 132 insertions, 0 deletions
diff --git a/linden/indra/llplugin/llpluginsharedmemory.h b/linden/indra/llplugin/llpluginsharedmemory.h
new file mode 100755
index 0000000..081d311
--- /dev/null
+++ b/linden/indra/llplugin/llpluginsharedmemory.h
@@ -0,0 +1,132 @@
1/**
2 * @file llpluginsharedmemory.h
3 *
4 * @cond
5 * $LicenseInfo:firstyear=2008&license=viewergpl$
6 *
7 * Copyright (c) 2008-2010, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlife.com/developers/opensource/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 *
32 * @endcond
33 */
34
35#ifndef LL_LLPLUGINSHAREDMEMORY_H
36#define LL_LLPLUGINSHAREDMEMORY_H
37
38class LLPluginSharedMemoryPlatformImpl;
39
40/**
41 * @brief LLPluginSharedMemory manages a shared memory segment for use by the LLPlugin API.
42 *
43 */
44class LLPluginSharedMemory
45{
46 LOG_CLASS(LLPluginSharedMemory);
47public:
48 LLPluginSharedMemory();
49 ~LLPluginSharedMemory();
50
51 // Parent will use create/destroy, child will use attach/detach.
52 // Message transactions will ensure child attaches after parent creates and detaches before parent destroys.
53
54 /**
55 * Creates a shared memory segment, with a name which is guaranteed to be unique on the host at the current time. Used by parent.
56 * Message transactions will (? TODO:DOC - should? must?) ensure child attaches after parent creates and detaches before parent destroys.
57 *
58 * @param[in] size Shared memory size in TODO:DOC units = bytes?.
59 *
60 * @return False for failure, true for success.
61 */
62 bool create(size_t size);
63 /**
64 * Destroys a shared memory segment. Used by parent.
65 * Message transactions will (? TODO:DOC - should? must?) ensure child attaches after parent creates and detaches before parent destroys.
66 *
67 * @return True. TODO:DOC - always returns true. Is this the intended behavior?
68 */
69 bool destroy(void);
70
71 /**
72 * Creates and attaches a name to a shared memory segment. TODO:DOC what's the difference between attach() and create()?
73 *
74 * @param[in] name Name to attach to memory segment
75 * @param[in] size Size of memory segment TODO:DOC in bytes?
76 *
77 * @return False on failure, true otherwise.
78 */
79 bool attach(const std::string &name, size_t size);
80 /**
81 * Detaches shared memory segment.
82 *
83 * @return False on failure, true otherwise.
84 */
85 bool detach(void);
86
87 /**
88 * Checks if shared memory is mapped to a non-null address.
89 *
90 * @return True if memory address is non-null, false otherwise.
91 */
92 bool isMapped(void) const { return (mMappedAddress != NULL); };
93 /**
94 * Get pointer to shared memory.
95 *
96 * @return Pointer to shared memory.
97 */
98 void *getMappedAddress(void) const { return mMappedAddress; };
99 /**
100 * Get size of shared memory.
101 *
102 * @return Size of shared memory in bytes. TODO:DOC are bytes the correct unit?
103 */
104 size_t getSize(void) const { return mSize; };
105 /**
106 * Get name of shared memory.
107 *
108 * @return Name of shared memory.
109 */
110 std::string getName() const { return mName; };
111
112private:
113 bool map(void);
114 bool unmap(void);
115 bool close(void);
116 bool unlink(void);
117
118 std::string mName;
119 size_t mSize;
120 void *mMappedAddress;
121 bool mNeedsDestroy;
122
123 LLPluginSharedMemoryPlatformImpl *mImpl;
124
125 static int sSegmentNumber;
126 static std::string createName();
127
128};
129
130
131
132#endif // LL_LLPLUGINSHAREDMEMORY_H