HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UT_SharedMemoryManager.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: UT_SharedMemoryManager.h ( UT Library, C++)
7
*
8
* COMMENTS:
9
*
10
*/
11
12
#ifndef __UT_SharedMemoryManager__
13
#define __UT_SharedMemoryManager__
14
15
#include "
UT_API.h
"
16
17
#include "
UT_Map.h
"
18
#include "
UT_StringMap.h
"
19
#include "
UT_SpinLock.h
"
20
21
class
SYS_SharedMemory
;
22
23
class
UT_API
UT_SharedMemoryManager
24
{
25
public
:
26
static
UT_SharedMemoryManager
&
get
();
27
28
// Creates a new memory block with the given identifier and size and marks
29
// it as being used.
30
bool
add
(
const
char
*key,
const
char
*
id
, int64_t
size
);
31
32
// Retrieves an existing memory block, or creates an empty one and marks
33
// it as being used.
34
SYS_SharedMemory
*
get
(
const
char
*key);
35
36
// Mark all shared memory blocks with keys matching the pattern as being
37
// unused. If a block is retrieved with get() it gets marked as used. Any
38
// blocks remaining unused after an operation can be erased by calling
39
// erase() with 'only_unused' set to true.
40
void
setUnused(
const
char
*
pattern
);
41
42
// Destroys all shared memory blocks with keys matching the given pattern.
43
//
44
void
erase(
const
char
*pattern,
bool
only_unused =
false
);
45
46
// Exit callback to destroy all known shared memory blocks, so they don't
47
// linger on-disk or in page file after the owning process dies.
48
static
void
exitCallback(
void
*);
49
private
:
50
UT_SharedMemoryManager
();
51
52
UT_SharedMemoryManager
(
const
UT_SharedMemoryManager
&) =
delete
;
53
UT_SharedMemoryManager
&
operator=
(
const
UT_SharedMemoryManager
&) =
delete
;
54
55
// Finds a list of keys matching the pattern. If all keys match the pattern
56
// the array is empty but the function still returns true.
57
bool
find
(
const
char
*pattern,
UT_Array<const char *>
&keys);
58
59
static
UT_SpinLock
theInstanceLock;
60
static
UT_SharedMemoryManager
*theInstance;
61
62
struct
ut_AutoSharedMemory
63
{
64
ut_AutoSharedMemory() : mySharedMemory(0), myUsed(
false
) {}
65
~ut_AutoSharedMemory();
66
67
ut_AutoSharedMemory(
const
ut_AutoSharedMemory &) =
delete
;
68
ut_AutoSharedMemory &
operator=
(
const
ut_AutoSharedMemory &) =
delete
;
69
70
SYS_SharedMemory
*mySharedMemory;
71
bool
myUsed;
72
};
73
74
typedef
UT_StringMap<ut_AutoSharedMemory>
ut_SharedMemPool
;
75
76
ut_SharedMemPool
mySharedMemPool;
77
};
78
79
#endif // __UT_SharedMemoryManager__
UT_StringMap< ut_AutoSharedMemory >
UT_API.h
UT_API
#define UT_API
Definition:
UT_API.h:14
detail::find
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition:
core.h:2138
UT_Array< const char * >
UT_SpinLockT< false, false >
UT_Map.h
pattern
GLushort pattern
Definition:
glad.h:2583
UT_SpinLock.h
size
GLsizeiptr size
Definition:
glcorearb.h:664
nanovdb::operator=
LeafData & operator=(const LeafData &)=delete
SYS_SharedMemory
Definition:
SYS_SharedMemory.h:26
ImageBufAlgo::add
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
UT_StringMap.h
UT_SharedMemoryManager
Definition:
UT_SharedMemoryManager.h:23
UT
UT_SharedMemoryManager.h
Generated on Mon Sep 22 2025 02:41:35 for HDK by
1.8.6