Maintains a set of global refereces to instances.
More...
Maintains a set of global refereces to instances.
Definition at line 11 of file JNIGlobalRefTable.cs.
◆ AddGlobalRef()
| static nint IKVM.Runtime.JNI.JNIGlobalRefTable.AddGlobalRef |
( |
object | o | ) |
|
|
static |
Adds a new global ref to the table.
- Parameters
-
- Returns
Definition at line 39 of file JNIGlobalRefTable.cs.
40 {
41 lock (globalRefs)
42 {
43 int index = globalRefs.IndexOf(null);
44 if (index >= 0)
45 {
46 globalRefs[index] = o;
47 }
48 else
49 {
50 index = globalRefs.Count;
51 globalRefs.Add(o);
52 }
53
54 return -(index + 1);
55 }
56 }
◆ AddWeakGlobalRef()
| static nint IKVM.Runtime.JNI.JNIGlobalRefTable.AddWeakGlobalRef |
( |
object | o | ) |
|
|
static |
Adds a new global ref to the table.
- Parameters
-
- Returns
Definition at line 73 of file JNIGlobalRefTable.cs.
74 {
75 lock (weakRefLock)
76 {
77 for (int i = 0; i < weakRefs.Length; i++)
78 {
79 if (weakRefs[i].IsAllocated == false)
80 {
81 weakRefs[i] = GCHandle.Alloc(o, GCHandleType.WeakTrackResurrection);
82 return -(i | (1 << 30));
83 }
84 }
85
86 var len = weakRefs.Length;
87 var tmp = new GCHandle[len * 2];
88 Array.Copy(weakRefs, 0, tmp, 0, len);
89 tmp[len] = GCHandle.Alloc(o, GCHandleType.WeakTrackResurrection);
90 weakRefs = tmp;
91 return -(len | (1 << 30));
92 }
93 }
◆ DeleteGlobalRef()
| static void IKVM.Runtime.JNI.JNIGlobalRefTable.DeleteGlobalRef |
( |
nint | o | ) |
|
|
static |
Deletes a global ref from the table.
- Parameters
-
Definition at line 62 of file JNIGlobalRefTable.cs.
63 {
64 lock (globalRefs)
65 globalRefs[(-(int)o) - 1] = null;
66 }
◆ DeleteWeakGlobalRef()
| static void IKVM.Runtime.JNI.JNIGlobalRefTable.DeleteWeakGlobalRef |
( |
nint | o | ) |
|
|
static |
Deletes a weak global ref from the table.
- Parameters
-
Definition at line 100 of file JNIGlobalRefTable.cs.
101 {
102 lock (weakRefLock)
103 weakRefs[-o - (1 << 30)].Free();
104 }
The documentation for this class was generated from the following file: