Gnash
0.8.11dev
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
libbase
SharedMem.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3
// Free Software Foundation, Inc
4
//
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
#ifndef GNASH_SHM_H
20
#define GNASH_SHM_H
21
22
#ifdef HAVE_CONFIG_H
23
# include "
gnashconfig.h
"
24
#endif
25
26
#include <boost/cstdint.hpp>
27
28
#if defined (WIN32)
29
// Include for HANDLE
30
#include <windows.h>
31
#else
32
// key_t
33
#include <sys/types.h>
34
#endif
35
36
#include "
dsodefs.h
"
//For DSOEXPORT
37
38
// Forward declarations
39
namespace
gnash {
40
class
fn_call;
41
}
42
43
namespace
gnash {
44
45
class
SharedMem
46
{
47
public
:
48
49
typedef
boost::uint8_t*
iterator
;
50
52
//
55
iterator
begin
()
const
{
56
return
_addr;
57
}
58
60
//
62
iterator
end
()
const
{
63
return
_addr + _size;
64
}
65
67
//
71
DSOEXPORT
SharedMem
(
size_t
size);
72
74
DSOEXPORT
~SharedMem
();
75
77
//
80
DSOEXPORT
bool
attach
();
81
83
class
Lock
84
{
85
public
:
86
Lock
(
const
SharedMem
&
s
) : _s(s), _locked(s.lock()) {}
87
~Lock
() {
if
(_locked) _s.unlock(); }
88
bool
locked
()
const
{
89
return
_locked;
90
}
91
private
:
92
const
SharedMem
& _s;
93
bool
_locked;
94
};
95
96
private
:
97
99
//
101
DSOEXPORT
bool
lock()
const
;
102
104
//
106
DSOEXPORT
bool
unlock()
const
;
107
110
bool
getSemaphore();
111
112
iterator
_addr;
113
114
const
size_t
_size;
115
116
// Semaphore ID.
117
int
_semid;
118
119
// Shared memory ID.
120
int
_shmid;
121
122
#if !defined(WIN32)
123
key_t _shmkey;
124
#else
125
long
_shmkey;
126
HANDLE _shmhandle;
127
#endif
128
};
129
131
//
136
inline
bool
137
attached
(
const
SharedMem
& mem) {
138
return
(mem.
begin
());
139
}
140
141
}
// end of gnash namespace
142
143
#endif
144
145
// Local Variables:
146
// mode: C++
147
// indent-tabs-mode: t
148
// End:
Generated on Sat Nov 30 2013 06:54:23 for Gnash by
1.8.1.2