GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

cpl_virtualmem.h
Go to the documentation of this file.
1 /**********************************************************************
2 * $Id: cpl_virtualmem.h 33666 2016-03-07 05:21:07Z goatbar $
3 *
4 * Name: cpl_virtualmem.h
5 * Project: CPL - Common Portability Library
6 * Purpose: Virtual memory
7 * Author: Even Rouault, <even dot rouault at mines dash paris dot org>
8 *
9 **********************************************************************
10 * Copyright (c) 2014, Even Rouault <even dot rouault at mines-paris dot org>
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 ****************************************************************************/
30
31 #ifndef CPL_VIRTUAL_MEM_INCLUDED
32 #define CPL_VIRTUAL_MEM_INCLUDED
33
34 #include "cpl_port.h"
35 #include "cpl_vsi.h"
36
37 CPL_C_START
38
60 typedef struct CPLVirtualMem CPLVirtualMem;
61
72 typedef void (*CPLVirtualMemCachePageCbk)(CPLVirtualMem* ctxt,
73 size_t nOffset,
74 void* pPageToFill,
75 size_t nToFill,
76 void* pUserData);
77
88 typedef void (*CPLVirtualMemUnCachePageCbk)(CPLVirtualMem* ctxt,
89 size_t nOffset,
90 const void* pPageToBeEvicted,
91 size_t nToBeEvicted,
92 void* pUserData);
93
97 typedef void (*CPLVirtualMemFreeUserData)(void* pUserData);
98
100 typedef enum
101 {
104 VIRTUALMEM_READONLY,
107 VIRTUALMEM_READONLY_ENFORCED,
110 VIRTUALMEM_READWRITE
111 } CPLVirtualMemAccessMode;
112
113
120 size_t CPL_DLL CPLGetPageSize(void);
121
166 CPLVirtualMem CPL_DLL *CPLVirtualMemNew(size_t nSize,
167 size_t nCacheSize,
168 size_t nPageSizeHint,
169 int bSingleThreadUsage,
170 CPLVirtualMemAccessMode eAccessMode,
171 CPLVirtualMemCachePageCbk pfnCachePage,
172 CPLVirtualMemUnCachePageCbk pfnUnCachePage,
173 CPLVirtualMemFreeUserData pfnFreeUserData,
174 void *pCbkUserData);
175
176
182 int CPL_DLL CPLIsVirtualMemFileMapAvailable(void);
183
210 CPLVirtualMem CPL_DLL *CPLVirtualMemFileMapNew( VSILFILE* fp,
211 vsi_l_offset nOffset,
212 vsi_l_offset nLength,
213 CPLVirtualMemAccessMode eAccessMode,
214 CPLVirtualMemFreeUserData pfnFreeUserData,
215 void *pCbkUserData );
216
236 CPLVirtualMem CPL_DLL *CPLVirtualMemDerivedNew(CPLVirtualMem* pVMemBase,
237 vsi_l_offset nOffset,
238 vsi_l_offset nSize,
239 CPLVirtualMemFreeUserData pfnFreeUserData,
240 void *pCbkUserData);
241
253 void CPL_DLL CPLVirtualMemFree(CPLVirtualMem* ctxt);
254
270 void CPL_DLL *CPLVirtualMemGetAddr(CPLVirtualMem* ctxt);
271
279 size_t CPL_DLL CPLVirtualMemGetSize(CPLVirtualMem* ctxt);
280
288 int CPL_DLL CPLVirtualMemIsFileMapping(CPLVirtualMem* ctxt);
289
297 CPLVirtualMemAccessMode CPL_DLL CPLVirtualMemGetAccessMode(CPLVirtualMem* ctxt);
298
309 size_t CPL_DLL CPLVirtualMemGetPageSize(CPLVirtualMem* ctxt);
310
328 int CPL_DLL CPLVirtualMemIsAccessThreadSafe(CPLVirtualMem* ctxt);
329
342 void CPL_DLL CPLVirtualMemDeclareThread(CPLVirtualMem* ctxt);
343
356 void CPL_DLL CPLVirtualMemUnDeclareThread(CPLVirtualMem* ctxt);
357
375 void CPL_DLL CPLVirtualMemPin(CPLVirtualMem* ctxt,
376 void* pAddr, size_t nSize, int bWriteOp);
377
385 void CPL_DLL CPLVirtualMemManagerTerminate(void);
386
387
388 CPL_C_END
389
390 #endif /* CPL_VIRTUAL_MEM_INCLUDED */
CPLVirtualMemGetPageSize
size_t CPLVirtualMemGetPageSize(CPLVirtualMem *ctxt)
Return the page size associated to a virtual memory mapping.
Definition: cpl_virtualmem.cpp:2164
cpl_vsi.h
Standard C Covers.
cpl_port.h
Core portability definitions for CPL.
CPLVirtualMemUnDeclareThread
void CPLVirtualMemUnDeclareThread(CPLVirtualMem *ctxt)
Declare that a thread will stop accessing a virtual memory mapping.
Definition: cpl_virtualmem.cpp:1922
CPLVirtualMem
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:60
CPLVirtualMemManagerTerminate
void CPLVirtualMemManagerTerminate(void)
Cleanup any resource and handlers related to virtual memory.
Definition: cpl_virtualmem.cpp:1930
CPLVirtualMemIsFileMapping
int CPLVirtualMemIsFileMapping(CPLVirtualMem *ctxt)
Return if the virtual memory mapping is a direct file mapping.
Definition: cpl_virtualmem.cpp:2146
VIRTUALMEM_READONLY
Definition: cpl_virtualmem.h:104
CPLVirtualMemDerivedNew
CPLVirtualMem * CPLVirtualMemDerivedNew(CPLVirtualMem *pVMemBase, vsi_l_offset nOffset, vsi_l_offset nSize, CPLVirtualMemFreeUserData pfnFreeUserData, void *pCbkUserData)
Create a new virtual memory mapping derived from an other virtual memory mapping. ...
Definition: cpl_virtualmem.cpp:2191
CPLVirtualMemCachePageCbk
void(* CPLVirtualMemCachePageCbk)(CPLVirtualMem *ctxt, size_t nOffset, void *pPageToFill, size_t nToFill, void *pUserData)
Callback triggered when a still unmapped page of virtual memory is accessed.
Definition: cpl_virtualmem.h:72
CPLIsVirtualMemFileMapAvailable
int CPLIsVirtualMemFileMapAvailable(void)
Return if virtual memory mapping of a file is available.
Definition: cpl_virtualmem.cpp:2091
CPLVirtualMemGetSize
size_t CPLVirtualMemGetSize(CPLVirtualMem *ctxt)
Return the size of the virtual memory mapping.
Definition: cpl_virtualmem.cpp:2173
CPLGetPageSize
size_t CPLGetPageSize(void)
Return the size of a page of virtual memory.
Definition: cpl_virtualmem.cpp:2078
CPLVirtualMemUnCachePageCbk
void(* CPLVirtualMemUnCachePageCbk)(CPLVirtualMem *ctxt, size_t nOffset, const void *pPageToBeEvicted, size_t nToBeEvicted, void *pUserData)
Callback triggered when a dirty mapped page is going to be freed.
Definition: cpl_virtualmem.h:88
CPLVirtualMemAccessMode
CPLVirtualMemAccessMode
Access mode of a virtual memory mapping.
Definition: cpl_virtualmem.h:100
CPLVirtualMemFree
void CPLVirtualMemFree(CPLVirtualMem *ctxt)
Free a virtual memory mapping.
Definition: cpl_virtualmem.cpp:2104
CPLVirtualMemIsAccessThreadSafe
int CPLVirtualMemIsAccessThreadSafe(CPLVirtualMem *ctxt)
Return TRUE if this memory mapping can be accessed safely from concurrent threads.
Definition: cpl_virtualmem.cpp:2182
CPLVirtualMemGetAccessMode
CPLVirtualMemAccessMode CPLVirtualMemGetAccessMode(CPLVirtualMem *ctxt)
Return the access mode of the virtual memory mapping.
Definition: cpl_virtualmem.cpp:2155
CPLVirtualMemPin
void CPLVirtualMemPin(CPLVirtualMem *ctxt, void *pAddr, size_t nSize, int bWriteOp)
Make sure that a region of virtual memory will be realized.
Definition: cpl_virtualmem.cpp:1924
CPLVirtualMemGetAddr
void * CPLVirtualMemGetAddr(CPLVirtualMem *ctxt)
Return the pointer to the start of a virtual memory mapping.
Definition: cpl_virtualmem.cpp:2137
CPLVirtualMemFreeUserData
void(* CPLVirtualMemFreeUserData)(void *pUserData)
Callback triggered when a virtual memory mapping is destroyed.
Definition: cpl_virtualmem.h:97
VIRTUALMEM_READWRITE
Definition: cpl_virtualmem.h:110
VIRTUALMEM_READONLY_ENFORCED
Definition: cpl_virtualmem.h:107
CPLVirtualMemNew
CPLVirtualMem * CPLVirtualMemNew(size_t nSize, size_t nCacheSize, size_t nPageSizeHint, int bSingleThreadUsage, CPLVirtualMemAccessMode eAccessMode, CPLVirtualMemCachePageCbk pfnCachePage, CPLVirtualMemUnCachePageCbk pfnUnCachePage, CPLVirtualMemFreeUserData pfnFreeUserData, void *pCbkUserData)
Create a new virtual memory mapping.
Definition: cpl_virtualmem.cpp:1904
CPLVirtualMemFileMapNew
CPLVirtualMem * CPLVirtualMemFileMapNew(VSILFILE *fp, vsi_l_offset nOffset, vsi_l_offset nLength, CPLVirtualMemAccessMode eAccessMode, CPLVirtualMemFreeUserData pfnFreeUserData, void *pCbkUserData)
Create a new virtual memory mapping from a file.
Definition: cpl_virtualmem.cpp:2058
CPLVirtualMemDeclareThread
void CPLVirtualMemDeclareThread(CPLVirtualMem *ctxt)
Declare that a thread will access a virtual memory mapping.
Definition: cpl_virtualmem.cpp:1920

Generated for GDAL by 1.8.8.