@daneren2005/shared-memory-objects 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -56
- package/dist/{src/allocated-memory.d.ts → allocated-memory.d.ts} +6 -4
- package/dist/allocated-memory.js +47 -37
- package/dist/allocated-memory.js.map +1 -1
- package/dist/{src/cached-item-list.d.ts → cached-item-list.d.ts} +5 -4
- package/dist/cached-item-list.js +75 -75
- package/dist/cached-item-list.js.map +1 -1
- package/dist/constant-string.d.ts +15 -0
- package/dist/constant-string.js +67 -0
- package/dist/constant-string.js.map +1 -0
- package/dist/interfaces/pow2.js +0 -2
- package/dist/interfaces/typed-array-constructor.js +0 -2
- package/dist/interfaces/typed-array.js +0 -2
- package/dist/{src/local-pool.d.ts → local-pool.d.ts} +2 -2
- package/dist/local-pool.js +89 -94
- package/dist/local-pool.js.map +1 -1
- package/dist/lock/read-write-lock.js +15 -21
- package/dist/lock/read-write-lock.js.map +1 -1
- package/dist/lock/simple-lock.js +9 -12
- package/dist/lock/simple-lock.js.map +1 -1
- package/dist/{src/memory-buffer.d.ts → memory-buffer.d.ts} +8 -5
- package/dist/memory-buffer.js +269 -326
- package/dist/memory-buffer.js.map +1 -1
- package/dist/{src/memory-heap.d.ts → memory-heap.d.ts} +4 -2
- package/dist/memory-heap.js +105 -115
- package/dist/memory-heap.js.map +1 -1
- package/dist/{src/serialize-object.d.ts → serialize-object.d.ts} +2 -2
- package/dist/serialize-object.js +43 -55
- package/dist/serialize-object.js.map +1 -1
- package/dist/{src/shared-list.d.ts → shared-list.d.ts} +11 -5
- package/dist/shared-list.js +162 -164
- package/dist/shared-list.js.map +1 -1
- package/dist/{src/shared-map.d.ts → shared-map.d.ts} +2 -2
- package/dist/shared-map.js +105 -138
- package/dist/shared-map.js.map +1 -1
- package/dist/{src/shared-pointer-list.d.ts → shared-pointer-list.d.ts} +4 -3
- package/dist/shared-pointer-list.js +49 -48
- package/dist/shared-pointer-list.js.map +1 -1
- package/dist/{src/shared-pool.d.ts → shared-pool.d.ts} +15 -8
- package/dist/shared-pool.js +151 -164
- package/dist/shared-pool.js.map +1 -1
- package/dist/shared-stack.d.ts +59 -0
- package/dist/shared-stack.js +221 -0
- package/dist/shared-stack.js.map +1 -0
- package/dist/{src/shared-string.d.ts → shared-string.d.ts} +2 -2
- package/dist/shared-string.js +72 -78
- package/dist/shared-string.js.map +1 -1
- package/dist/{src/shared-vector.d.ts → shared-vector.d.ts} +5 -4
- package/dist/shared-vector.js +150 -164
- package/dist/shared-vector.js.map +1 -1
- package/dist/utils/16-from-32-array.js +14 -16
- package/dist/utils/16-from-32-array.js.map +1 -1
- package/dist/utils/16-from-64-array.js +15 -10
- package/dist/utils/16-from-64-array.js.map +1 -1
- package/dist/utils/atomic-math.js +30 -32
- package/dist/utils/atomic-math.js.map +1 -1
- package/dist/utils/float32-atomics.js +18 -22
- package/dist/utils/float32-atomics.js.map +1 -1
- package/dist/utils/float64-atomics.js +18 -22
- package/dist/utils/float64-atomics.js.map +1 -1
- package/dist/utils/pointer.js +34 -44
- package/dist/utils/pointer.js.map +1 -1
- package/dist/{src/utils → utils}/typedarray.d.ts +47 -47
- package/dist/utils/typedarray.js +36 -43
- package/dist/utils/typedarray.js.map +1 -1
- package/package.json +23 -22
- package/dist/interfaces/pow2.js.map +0 -1
- package/dist/interfaces/typed-array-constructor.js.map +0 -1
- package/dist/interfaces/typed-array.js.map +0 -1
- /package/dist/{src/interfaces → interfaces}/pow2.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/typed-array-constructor.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/typed-array.d.ts +0 -0
- /package/dist/{src/lock → lock}/read-write-lock.d.ts +0 -0
- /package/dist/{src/lock → lock}/simple-lock.d.ts +0 -0
- /package/dist/{src/utils → utils}/16-from-32-array.d.ts +0 -0
- /package/dist/{src/utils → utils}/16-from-64-array.d.ts +0 -0
- /package/dist/{src/utils → utils}/atomic-math.d.ts +0 -0
- /package/dist/{src/utils → utils}/float32-atomics.d.ts +0 -0
- /package/dist/{src/utils → utils}/float64-atomics.d.ts +0 -0
- /package/dist/{src/utils → utils}/pointer.d.ts +0 -0
package/dist/shared-map.js
CHANGED
|
@@ -1,140 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
class
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
for (let { data: n } of h)
|
|
95
|
-
this.setHashKey(r, e, n[0], n[1]);
|
|
96
|
-
h.free();
|
|
97
|
-
}
|
|
98
|
-
y(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e), s.free();
|
|
99
|
-
}
|
|
100
|
-
hash(t, e) {
|
|
101
|
-
return t % e;
|
|
102
|
-
}
|
|
103
|
-
free() {
|
|
104
|
-
for (let t = 0; t < this.maxHash; t++) {
|
|
105
|
-
let e = l(this.hashMemory.data, t);
|
|
106
|
-
if (e.bufferByteOffset === 0)
|
|
107
|
-
continue;
|
|
108
|
-
new f(this.memory, {
|
|
109
|
-
firstBlock: e
|
|
110
|
-
}).free();
|
|
111
|
-
}
|
|
112
|
-
this.hashMemory.free(), this.pointerMemory.free();
|
|
113
|
-
}
|
|
114
|
-
getSharedMemory() {
|
|
115
|
-
return {
|
|
116
|
-
firstBlock: this.pointerMemory.getSharedMemory()
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function m(o) {
|
|
121
|
-
return typeof o == "number" ? o : typeof o == "string" ? p(o) : o;
|
|
1
|
+
import { loadPointer as e, storePointer as t } from "./utils/pointer.js";
|
|
2
|
+
import n from "./allocated-memory.js";
|
|
3
|
+
import r from "./shared-list.js";
|
|
4
|
+
//#region src/shared-map.ts
|
|
5
|
+
var i = 10, a = class a {
|
|
6
|
+
static ALLOCATE_COUNT = 4;
|
|
7
|
+
memory;
|
|
8
|
+
pointerMemory;
|
|
9
|
+
lock;
|
|
10
|
+
get hashMemory() {
|
|
11
|
+
return new n(this.memory, e(this.pointerMemory.data, 0));
|
|
12
|
+
}
|
|
13
|
+
get length() {
|
|
14
|
+
return Atomics.load(this.pointerMemory.data, 2);
|
|
15
|
+
}
|
|
16
|
+
get maxHash() {
|
|
17
|
+
return Atomics.load(this.pointerMemory.data, 3);
|
|
18
|
+
}
|
|
19
|
+
constructor(e, r) {
|
|
20
|
+
if (this.memory = e, r) this.pointerMemory = new n(e, r.firstBlock);
|
|
21
|
+
else {
|
|
22
|
+
this.pointerMemory = e.allocUI32(a.ALLOCATE_COUNT);
|
|
23
|
+
let n = e.allocUI32(i);
|
|
24
|
+
t(this.pointerMemory.data, 0, n.bufferPosition, n.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, i);
|
|
25
|
+
}
|
|
26
|
+
this.lock = new Int32Array(this.pointerMemory.data.buffer, this.pointerMemory.bufferByteOffset + Uint32Array.BYTES_PER_ELEMENT, 1);
|
|
27
|
+
}
|
|
28
|
+
set(e, t) {
|
|
29
|
+
this.length >= this.maxHash * 2 && this.growHashTable();
|
|
30
|
+
let n = o(e);
|
|
31
|
+
this.setHashKey(this.hashMemory, this.maxHash, n, t) && Atomics.add(this.pointerMemory.data, 2, 1);
|
|
32
|
+
}
|
|
33
|
+
setHashKey(n, i, a, o) {
|
|
34
|
+
let s = this.hash(a, i), c, l = e(n.data, s);
|
|
35
|
+
if (l.bufferByteOffset === 0) {
|
|
36
|
+
c = new r(this.memory, { dataLength: 2 });
|
|
37
|
+
let e = c.getSharedMemory();
|
|
38
|
+
t(n.data, s, e.firstBlock.bufferPosition, e.firstBlock.bufferByteOffset);
|
|
39
|
+
} else c = new r(this.memory, { firstBlock: l });
|
|
40
|
+
let u = !0;
|
|
41
|
+
return c.deleteValue(a) && (u = !1), c.insert([a, o]), u || c.compact(), u;
|
|
42
|
+
}
|
|
43
|
+
get(t) {
|
|
44
|
+
let n = o(t), i = this.hash(n, this.maxHash), a = e(this.hashMemory.data, i);
|
|
45
|
+
if (a.bufferByteOffset === 0) return;
|
|
46
|
+
let s = new r(this.memory, { firstBlock: a });
|
|
47
|
+
for (let { data: e } of s) if (e[0] === n) return e[1];
|
|
48
|
+
}
|
|
49
|
+
has(t) {
|
|
50
|
+
let n = o(t), i = this.hash(n, this.maxHash), a = e(this.hashMemory.data, i);
|
|
51
|
+
if (a.bufferByteOffset === 0) return !1;
|
|
52
|
+
let s = new r(this.memory, { firstBlock: a });
|
|
53
|
+
for (let { data: e } of s) if (e[0] === n) return !0;
|
|
54
|
+
return !1;
|
|
55
|
+
}
|
|
56
|
+
delete(t) {
|
|
57
|
+
let n = o(t), i = this.hash(n, this.maxHash), a = e(this.hashMemory.data, i);
|
|
58
|
+
if (a.bufferByteOffset === 0) return !1;
|
|
59
|
+
let s = new r(this.memory, { firstBlock: a }), c = !1;
|
|
60
|
+
for (let { data: e, deleteCurrent: t } of s) if (e[0] === n) {
|
|
61
|
+
t(), Atomics.sub(this.pointerMemory.data, 2, 1), c = !0;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return c && s.compact(), c;
|
|
65
|
+
}
|
|
66
|
+
growHashTable() {
|
|
67
|
+
let n = this.maxHash, i = n * 2, a = this.memory.allocUI32(i), o = this.hashMemory;
|
|
68
|
+
for (let t = 0; t < n; t++) {
|
|
69
|
+
let n = e(o.data, t);
|
|
70
|
+
if (n.bufferByteOffset === 0) continue;
|
|
71
|
+
let s = new r(this.memory, { firstBlock: n });
|
|
72
|
+
for (let { data: e } of s) this.setHashKey(a, i, e[0], e[1]);
|
|
73
|
+
s.free();
|
|
74
|
+
}
|
|
75
|
+
t(this.pointerMemory.data, 0, a.bufferPosition, a.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, i), o.free();
|
|
76
|
+
}
|
|
77
|
+
hash(e, t) {
|
|
78
|
+
return e % t;
|
|
79
|
+
}
|
|
80
|
+
free() {
|
|
81
|
+
for (let t = 0; t < this.maxHash; t++) {
|
|
82
|
+
let n = e(this.hashMemory.data, t);
|
|
83
|
+
n.bufferByteOffset !== 0 && new r(this.memory, { firstBlock: n }).free();
|
|
84
|
+
}
|
|
85
|
+
this.hashMemory.free(), this.pointerMemory.free();
|
|
86
|
+
}
|
|
87
|
+
getSharedMemory() {
|
|
88
|
+
return { firstBlock: this.pointerMemory.getSharedMemory() };
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
function o(e) {
|
|
92
|
+
return typeof e == "number" ? e : typeof e == "string" ? s(e) : e;
|
|
122
93
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
case 1:
|
|
133
|
-
e ^= o.charCodeAt(r) & 255, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16);
|
|
134
|
-
}
|
|
135
|
-
return e ^= e >>> 13, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16), e ^= e >>> 15, e = e >>> 0, e;
|
|
94
|
+
function s(e) {
|
|
95
|
+
let t = e.length, n = 17 ^ t, r = 0, i;
|
|
96
|
+
for (; t >= 4;) i = e.charCodeAt(r) & 255 | (e.charCodeAt(++r) & 255) << 8 | (e.charCodeAt(++r) & 255) << 16 | (e.charCodeAt(++r) & 255) << 14, i = (i & 65535) * 1540483477 + (((i >>> 16) * 1540483477 & 65535) << 16), i ^= i >>> 14, i = (i & 65535) * 1540483477 + (((i >>> 16) * 1540483477 & 65535) << 16), n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16) ^ i, t -= 4, ++r;
|
|
97
|
+
switch (t) {
|
|
98
|
+
case 3: n ^= (e.charCodeAt(r + 2) & 255) << 16;
|
|
99
|
+
case 2: n ^= (e.charCodeAt(r + 1) & 255) << 8;
|
|
100
|
+
case 1: n ^= e.charCodeAt(r) & 255, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16);
|
|
101
|
+
}
|
|
102
|
+
return n ^= n >>> 13, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16), n ^= n >>> 15, n >>>= 0, n;
|
|
136
103
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
//# sourceMappingURL=shared-map.js.map
|
|
104
|
+
//#endregion
|
|
105
|
+
export { a as default };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=shared-map.js.map
|
package/dist/shared-map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-map.js","sources":["../src/shared-map.ts"],"sourcesContent":["import AllocatedMemory, { type SharedAllocatedMemory } from './allocated-memory';\nimport type MemoryHeap from './memory-heap';\nimport SharedList from './shared-list';\nimport { loadPointer, storePointer } from './utils/pointer';\n\n// TODO: Grow hashMemory\n// TODO: Add iterator\n// TODO: Add read/write locks\nconst DEFAULT_HASH_SIZE = 10;\nexport default class SharedMap<K extends string | number> {\n\tstatic readonly ALLOCATE_COUNT = 4;\n\n\tprivate memory: MemoryHeap;\n\t// Memory order: Pointer, Lock, Length, MaxHash\n\tprivate pointerMemory: AllocatedMemory;\n\tprivate lock: Int32Array;\n\tprivate get hashMemory(): AllocatedMemory {\n\t\treturn new AllocatedMemory(this.memory, loadPointer(this.pointerMemory.data, 0));\n\t}\n\n\tget length(): number {\n\t\treturn Atomics.load(this.pointerMemory.data, 2);\n\t}\n\tget maxHash(): number {\n\t\treturn Atomics.load(this.pointerMemory.data, 3);\n\t}\n\n\tconstructor(memory: MemoryHeap, clone?: SharedMapMemory) {\n\t\tthis.memory = memory;\n\n\t\tif(clone) {\n\t\t\tthis.pointerMemory = new AllocatedMemory(memory, clone.firstBlock);\n\t\t} else {\n\t\t\tthis.pointerMemory = memory.allocUI32(SharedMap.ALLOCATE_COUNT);\n\t\t\tlet hashMemory = memory.allocUI32(DEFAULT_HASH_SIZE);\n\t\t\tstorePointer(this.pointerMemory.data, 0, hashMemory.bufferPosition, hashMemory.bufferByteOffset);\n\t\t\tAtomics.store(this.pointerMemory.data, 3, DEFAULT_HASH_SIZE);\n\t\t}\n\t\tthis.lock = new Int32Array(this.pointerMemory.data.buffer, this.pointerMemory.bufferByteOffset + Uint32Array.BYTES_PER_ELEMENT, 1);\n\t}\n\n\tset(key: K, value: number) {\n\t\tif(this.length >= this.maxHash * 2) {\n\t\t\tthis.growHashTable();\n\t\t}\n\n\t\tlet fullHashKey = get32BitHash(key);\n\t\tif(this.setHashKey(this.hashMemory, this.maxHash, fullHashKey, value)) {\n\t\t\tAtomics.add(this.pointerMemory.data, 2, 1);\n\t\t}\n\t}\n\tprivate setHashKey(hashMemory: AllocatedMemory, maxHash: number, fullHashKey: number, value: number) {\n\t\tlet hashKey = this.hash(fullHashKey, maxHash);\n\t\t\n\t\tlet list: SharedList;\n\t\tlet pointer = loadPointer(hashMemory.data, hashKey);\n\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\t// Initialize a list here\n\t\t\tlist = new SharedList(this.memory, {\n\t\t\t\tdataLength: 2\n\t\t\t});\n\n\t\t\tlet listMemory = list.getSharedMemory();\n\t\t\tstorePointer(hashMemory.data, hashKey, listMemory.firstBlock.bufferPosition, listMemory.firstBlock.bufferByteOffset);\n\t\t} else {\n\t\t\tlist = new SharedList(this.memory, {\n\t\t\t\tfirstBlock: pointer\n\t\t\t});\n\t\t}\n\n\t\t// Check if any other items in list have the same key and delete them\n\t\tlet inserted = true;\n\t\tif(list.deleteValue(fullHashKey)) {\n\t\t\tinserted = false;\n\t\t}\n\t\tlist.insert([fullHashKey, value]);\n\t\t\n\t\treturn inserted;\n\t}\n\n\tget(key: K): number | undefined {\n\t\tlet fullHashKey = get32BitHash(key);\n\t\tlet hashKey = this.hash(fullHashKey, this.maxHash);\n\n\t\tlet pointer = loadPointer(this.hashMemory.data, hashKey);\n\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tlet list = new SharedList(this.memory, {\n\t\t\tfirstBlock: pointer\n\t\t});\n\n\t\tfor(let { data } of list) {\n\t\t\tif(data[0] === fullHashKey) {\n\t\t\t\treturn data[1];\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\thas(key: K): boolean {\n\t\tlet fullHashKey = get32BitHash(key);\n\t\tlet hashKey = this.hash(fullHashKey, this.maxHash);\n\n\t\tlet pointer = loadPointer(this.hashMemory.data, hashKey);\n\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet list = new SharedList(this.memory, {\n\t\t\tfirstBlock: pointer\n\t\t});\n\n\t\tfor(let { data } of list) {\n\t\t\tif(data[0] === fullHashKey) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tdelete(key: K): boolean {\n\t\tlet fullHashKey = get32BitHash(key);\n\t\tlet hashKey = this.hash(fullHashKey, this.maxHash);\n\n\t\tlet pointer = loadPointer(this.hashMemory.data, hashKey);\n\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet list = new SharedList(this.memory, {\n\t\t\tfirstBlock: pointer\n\t\t});\n\n\t\tfor(let { data, deleteCurrent } of list) {\n\t\t\tif(data[0] === fullHashKey) {\n\t\t\t\tdeleteCurrent();\n\n\t\t\t\tAtomics.sub(this.pointerMemory.data, 2, 1);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate growHashTable() {\n\t\tlet oldMaxHash = this.maxHash;\n\t\tlet newMaxHash = oldMaxHash * 2;\n\t\tlet newHashMemory = this.memory.allocUI32(newMaxHash);\n\t\tlet oldHashMemory = this.hashMemory;\n\n\t\t// Copy each old hash value into new hash memory\n\t\tfor(let i = 0; i < oldMaxHash; i++) {\n\t\t\tlet pointer = loadPointer(oldHashMemory.data, i);\n\t\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet list = new SharedList(this.memory, {\n\t\t\t\tfirstBlock: pointer\n\t\t\t});\n\t\t\tfor(let { data } of list) {\n\t\t\t\tthis.setHashKey(newHashMemory, newMaxHash, data[0], data[1]);\n\t\t\t}\n\n\t\t\t// The entries have been copied into freshly allocated lists in the new hash table so the old list can be freed\n\t\t\tlist.free();\n\t\t}\n\n\t\tstorePointer(this.pointerMemory.data, 0, newHashMemory.bufferPosition, newHashMemory.bufferByteOffset);\n\t\tAtomics.store(this.pointerMemory.data, 3, newMaxHash);\n\n\t\t// pointerMemory now references newHashMemory so the old hash table memory can be freed\n\t\toldHashMemory.free();\n\t}\n\n\tprivate hash(key: number, maxHash: number) {\n\t\treturn key % maxHash;\n\t}\n\n\tfree() {\n\t\t// Loop through and free lists in hash table first\n\t\tfor(let i = 0; i < this.maxHash; i++) {\n\t\t\tlet pointer = loadPointer(this.hashMemory.data, i);\n\t\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet list = new SharedList(this.memory, {\n\t\t\t\tfirstBlock: pointer\n\t\t\t});\n\t\t\tlist.free();\n\t\t}\n\n\t\tthis.hashMemory.free();\n\t\tthis.pointerMemory.free();\n\t}\n\n\tgetSharedMemory(): SharedMapMemory {\n\t\treturn {\n\t\t\tfirstBlock: this.pointerMemory.getSharedMemory()\n\t\t};\n\t}\n}\n\ninterface SharedMapMemory {\n\tfirstBlock: SharedAllocatedMemory\n}\n\nfunction get32BitHash<K extends string | number>(key: K): number {\n\tif(typeof key === 'number') {\n\t\treturn key;\n\t} else if(typeof key === 'string') {\n\t\treturn hashString(key as string);\n\t} else {\n\t\treturn key;\n\t}\n}\n\n// Copied from https://github.com/mmomtchev/SharedMap/blob/master/index.js - MurmurHash2\nfunction hashString(str: string): number {\n\tlet\n\t\tl = str.length,\n\t\th = 17 ^ l,\n\t\ti = 0,\n\t\tk;\n\twhile(l >= 4) {\n\t\tk =\n\t\t\t((str.charCodeAt(i) & 0xff)) |\n\t\t\t((str.charCodeAt(++i) & 0xff) << 8) |\n\t\t\t((str.charCodeAt(++i) & 0xff) << 16) |\n\t\t\t((str.charCodeAt(++i) & 0xff) << 14);\n\t\tk = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\t\tk ^= k >>> 14;\n\t\tk = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\t\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;\n\t\tl -= 4;\n\t\t++i;\n\t}\n\t/* eslint-disable no-fallthrough */\n\tswitch(l) {\n\t\tcase 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n\t\tcase 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n\t\tcase 1: h ^= (str.charCodeAt(i) & 0xff);\n\t\t\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\t}\n\t/* eslint-enable no-fallthrough */\n\th ^= h >>> 13;\n\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\th ^= h >>> 15;\n\th = h >>> 0;\n\treturn h;\n}\n\nexport type { SharedMapMemory };"],"names":["DEFAULT_HASH_SIZE","SharedMap","AllocatedMemory","loadPointer","memory","clone","hashMemory","storePointer","key","value","fullHashKey","get32BitHash","maxHash","hashKey","list","pointer","SharedList","listMemory","inserted","data","deleteCurrent","oldMaxHash","newMaxHash","newHashMemory","oldHashMemory","i","hashString","str","l","h","k"],"mappings":";;;AAQA,MAAMA,IAAoB;AAC1B,MAAqBC,EAAqC;AAAA,EACzD,OAAgB,iBAAiB;AAAA,EAEzB;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACR,IAAY,aAA8B;AACzC,WAAO,IAAIC,EAAgB,KAAK,QAAQC,EAAY,KAAK,cAAc,MAAM,CAAC,CAAC;AAAA,EAChF;AAAA,EAEA,IAAI,SAAiB;AACpB,WAAO,QAAQ,KAAK,KAAK,cAAc,MAAM,CAAC;AAAA,EAC/C;AAAA,EACA,IAAI,UAAkB;AACrB,WAAO,QAAQ,KAAK,KAAK,cAAc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AEjD;AACD;AAMA,SAASJ,EAAwCH,GAAgB;AAChE,SAAG,OAAOA,KAAQ,WACVA,IACE,OAAOA,KAAQ,WACjBkB,EAAWlB,CAAa,IAExBA;AAET;AAGA,SAASkB,EAAWC,GAAqB;AACxC,MACCC,IAAID,EAAI,QACRE,IAAI,KAAKD,GACTH,IAAI,GACJK;AACD,SAAMF,KAAK;AACV,IAAAE,IACGH,EAAI,WAAWF,CAAC,IAAI,OACpBE,EAAI,WAAW,EAAEF,CAAC,IAAI,QAAS,KAC/BE,EAAI,WAAW,EAAEF,CAAC,IAAI,QAAS,MAC/BE,EAAI,WAAW,EAAEF,CAAC,IAAI,QAAS,IAClCK,KAAOA,IAAI,SAAU,gBAAkBA,MAAM,MAAM,aAAc,UAAW,KAC5EA,KAAKA,MAAM,IACXA,KAAOA,IAAI,SAAU,gBAAkBA,MAAM,MAAM,aAAc,UAAW,KAC5ED,KAAOA,IAAI,SAAU,gBAAkBA,MAAM,MAAM,aAAc,UAAW,MAAOC,GACnFF,KAAK,GACL,EAAEH;AAGH,UAAOG,GAAA;AAAA,IACN,KAAK;AAAG,MAAAC,MAAMF,EAAI,WAAWF,IAAI,CAAC,IAAI,QAAS;AAAA,IAC/C,KAAK;AAAG,MAAAI,MAAMF,EAAI,WAAWF,IAAI,CAAC,IAAI,QAAS;AAAA,IAC/C,KAAK;AAAG,MAAAI,KAAMF,EAAI,WAAWF,CAAC,IAAI,KACjCI,KAAOA,IAAI,SAAU,gBAAkBA,MAAM,MAAM,aAAc,UAAW;AAAA,EAAA;AAG9E,SAAAA,KAAKA,MAAM,IACXA,KAAOA,IAAI,SAAU,gBAAkBA,MAAM,MAAM,aAAc,UAAW,KAC5EA,KAAKA,MAAM,IACXA,IAAIA,MAAM,GACHA;AACR;"}
|
|
1
|
+
{"version":3,"file":"shared-map.js","names":[],"sources":["../src/shared-map.ts"],"sourcesContent":["import AllocatedMemory, { type SharedAllocatedMemory } from './allocated-memory';\nimport type MemoryHeap from './memory-heap';\nimport SharedList from './shared-list';\nimport { loadPointer, storePointer } from './utils/pointer';\n\n// TODO: Grow hashMemory\n// TODO: Add iterator\n// TODO: Add read/write locks\nconst DEFAULT_HASH_SIZE = 10;\nexport default class SharedMap<K extends string | number> {\n\tstatic readonly ALLOCATE_COUNT = 4;\n\n\tprivate memory: MemoryHeap;\n\t// Memory order: Pointer, Lock, Length, MaxHash\n\tprivate pointerMemory: AllocatedMemory;\n\tprivate lock: Int32Array;\n\tprivate get hashMemory(): AllocatedMemory {\n\t\treturn new AllocatedMemory(this.memory, loadPointer(this.pointerMemory.data, 0));\n\t}\n\n\tget length(): number {\n\t\treturn Atomics.load(this.pointerMemory.data, 2);\n\t}\n\tget maxHash(): number {\n\t\treturn Atomics.load(this.pointerMemory.data, 3);\n\t}\n\n\tconstructor(memory: MemoryHeap, clone?: SharedMapMemory) {\n\t\tthis.memory = memory;\n\n\t\tif(clone) {\n\t\t\tthis.pointerMemory = new AllocatedMemory(memory, clone.firstBlock);\n\t\t} else {\n\t\t\tthis.pointerMemory = memory.allocUI32(SharedMap.ALLOCATE_COUNT);\n\t\t\tlet hashMemory = memory.allocUI32(DEFAULT_HASH_SIZE);\n\t\t\tstorePointer(this.pointerMemory.data, 0, hashMemory.bufferPosition, hashMemory.bufferByteOffset);\n\t\t\tAtomics.store(this.pointerMemory.data, 3, DEFAULT_HASH_SIZE);\n\t\t}\n\t\tthis.lock = new Int32Array(this.pointerMemory.data.buffer, this.pointerMemory.bufferByteOffset + Uint32Array.BYTES_PER_ELEMENT, 1);\n\t}\n\n\tset(key: K, value: number) {\n\t\tif(this.length >= this.maxHash * 2) {\n\t\t\tthis.growHashTable();\n\t\t}\n\n\t\tlet fullHashKey = get32BitHash(key);\n\t\tif(this.setHashKey(this.hashMemory, this.maxHash, fullHashKey, value)) {\n\t\t\tAtomics.add(this.pointerMemory.data, 2, 1);\n\t\t}\n\t}\n\tprivate setHashKey(hashMemory: AllocatedMemory, maxHash: number, fullHashKey: number, value: number) {\n\t\tlet hashKey = this.hash(fullHashKey, maxHash);\n\t\t\n\t\tlet list: SharedList;\n\t\tlet pointer = loadPointer(hashMemory.data, hashKey);\n\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\t// Initialize a list here\n\t\t\tlist = new SharedList(this.memory, {\n\t\t\t\tdataLength: 2,\n\t\t\t});\n\n\t\t\tlet listMemory = list.getSharedMemory();\n\t\t\tstorePointer(hashMemory.data, hashKey, listMemory.firstBlock.bufferPosition, listMemory.firstBlock.bufferByteOffset);\n\t\t} else {\n\t\t\tlist = new SharedList(this.memory, {\n\t\t\t\tfirstBlock: pointer,\n\t\t\t});\n\t\t}\n\n\t\t// Check if any other items in list have the same key and delete them\n\t\tlet inserted = true;\n\t\tif(list.deleteValue(fullHashKey)) {\n\t\t\tinserted = false;\n\t\t}\n\t\tlist.insert([fullHashKey, value]);\n\t\t// An overwrite leaves a tombstone behind - reclaim it so buckets don't grow on repeated updates\n\t\tif(!inserted) {\n\t\t\tlist.compact();\n\t\t}\n\n\t\treturn inserted;\n\t}\n\n\tget(key: K): number | undefined {\n\t\tlet fullHashKey = get32BitHash(key);\n\t\tlet hashKey = this.hash(fullHashKey, this.maxHash);\n\n\t\tlet pointer = loadPointer(this.hashMemory.data, hashKey);\n\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tlet list = new SharedList(this.memory, {\n\t\t\tfirstBlock: pointer,\n\t\t});\n\n\t\tfor(let { data } of list) {\n\t\t\tif(data[0] === fullHashKey) {\n\t\t\t\treturn data[1];\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\thas(key: K): boolean {\n\t\tlet fullHashKey = get32BitHash(key);\n\t\tlet hashKey = this.hash(fullHashKey, this.maxHash);\n\n\t\tlet pointer = loadPointer(this.hashMemory.data, hashKey);\n\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet list = new SharedList(this.memory, {\n\t\t\tfirstBlock: pointer,\n\t\t});\n\n\t\tfor(let { data } of list) {\n\t\t\tif(data[0] === fullHashKey) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tdelete(key: K): boolean {\n\t\tlet fullHashKey = get32BitHash(key);\n\t\tlet hashKey = this.hash(fullHashKey, this.maxHash);\n\n\t\tlet pointer = loadPointer(this.hashMemory.data, hashKey);\n\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet list = new SharedList(this.memory, {\n\t\t\tfirstBlock: pointer,\n\t\t});\n\n\t\tlet deleted = false;\n\t\tfor(let { data, deleteCurrent } of list) {\n\t\t\tif(data[0] === fullHashKey) {\n\t\t\t\tdeleteCurrent();\n\n\t\t\t\tAtomics.sub(this.pointerMemory.data, 2, 1);\n\t\t\t\tdeleted = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// compact only after iteration finishes - unlinking/freeing mid-iteration would corrupt the walk\n\t\tif(deleted) {\n\t\t\tlist.compact();\n\t\t}\n\n\t\treturn deleted;\n\t}\n\n\tprivate growHashTable() {\n\t\tlet oldMaxHash = this.maxHash;\n\t\tlet newMaxHash = oldMaxHash * 2;\n\t\tlet newHashMemory = this.memory.allocUI32(newMaxHash);\n\t\tlet oldHashMemory = this.hashMemory;\n\n\t\t// Copy each old hash value into new hash memory\n\t\tfor(let i = 0; i < oldMaxHash; i++) {\n\t\t\tlet pointer = loadPointer(oldHashMemory.data, i);\n\t\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet list = new SharedList(this.memory, {\n\t\t\t\tfirstBlock: pointer,\n\t\t\t});\n\t\t\tfor(let { data } of list) {\n\t\t\t\tthis.setHashKey(newHashMemory, newMaxHash, data[0], data[1]);\n\t\t\t}\n\n\t\t\t// The entries have been copied into freshly allocated lists in the new hash table so the old list can be freed\n\t\t\tlist.free();\n\t\t}\n\n\t\tstorePointer(this.pointerMemory.data, 0, newHashMemory.bufferPosition, newHashMemory.bufferByteOffset);\n\t\tAtomics.store(this.pointerMemory.data, 3, newMaxHash);\n\n\t\t// pointerMemory now references newHashMemory so the old hash table memory can be freed\n\t\toldHashMemory.free();\n\t}\n\n\tprivate hash(key: number, maxHash: number) {\n\t\treturn key % maxHash;\n\t}\n\n\tfree() {\n\t\t// Loop through and free lists in hash table first\n\t\tfor(let i = 0; i < this.maxHash; i++) {\n\t\t\tlet pointer = loadPointer(this.hashMemory.data, i);\n\t\t\tif(pointer.bufferByteOffset === 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet list = new SharedList(this.memory, {\n\t\t\t\tfirstBlock: pointer,\n\t\t\t});\n\t\t\tlist.free();\n\t\t}\n\n\t\tthis.hashMemory.free();\n\t\tthis.pointerMemory.free();\n\t}\n\n\tgetSharedMemory(): SharedMapMemory {\n\t\treturn {\n\t\t\tfirstBlock: this.pointerMemory.getSharedMemory(),\n\t\t};\n\t}\n}\n\ninterface SharedMapMemory {\n\tfirstBlock: SharedAllocatedMemory\n}\n\nfunction get32BitHash<K extends string | number>(key: K): number {\n\tif(typeof key === 'number') {\n\t\treturn key;\n\t} else if(typeof key === 'string') {\n\t\treturn hashString(key);\n\t} else {\n\t\treturn key;\n\t}\n}\n\n// Copied from https://github.com/mmomtchev/SharedMap/blob/master/index.js - MurmurHash2\nfunction hashString(str: string): number {\n\tlet\n\t\tl = str.length,\n\t\th = 17 ^ l,\n\t\ti = 0,\n\t\tk;\n\twhile(l >= 4) {\n\t\tk =\n\t\t\t((str.charCodeAt(i) & 0xff)) |\n\t\t\t((str.charCodeAt(++i) & 0xff) << 8) |\n\t\t\t((str.charCodeAt(++i) & 0xff) << 16) |\n\t\t\t((str.charCodeAt(++i) & 0xff) << 14);\n\t\tk = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\t\tk ^= k >>> 14;\n\t\tk = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\t\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;\n\t\tl -= 4;\n\t\t++i;\n\t}\n\t/* eslint-disable no-fallthrough */\n\tswitch(l) {\n\t\tcase 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n\t\tcase 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n\t\tcase 1: h ^= (str.charCodeAt(i) & 0xff);\n\t\t\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\t}\n\t/* eslint-enable no-fallthrough */\n\th ^= h >>> 13;\n\th = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));\n\th ^= h >>> 15;\n\th = h >>> 0;\n\treturn h;\n}\n\nexport type { SharedMapMemory };"],"mappings":";;;;AAQA,IAAM,IAAoB,IACL,IAArB,MAAqB,EAAqC;CACzD,OAAgB,iBAAiB;CAEjC;CAEA;CACA;CACA,IAAY,aAA8B;EACzC,OAAO,IAAI,EAAgB,KAAK,QAAQ,EAAY,KAAK,cAAc,MAAM,CAAC,CAAC;CAChF;CAEA,IAAI,SAAiB;EACpB,OAAO,QAAQ,KAAK,KAAK,cAAc,MAAM,CAAC;CAC/C;CACA,IAAI,UAAkB;EACrB,OAAO,QAAQ,KAAK,KAAK,cAAc,MAAM,CAAC;CAC/C;CAEA,YAAY,GAAoB,GAAyB;EAGxD,IAFA,KAAK,SAAS,GAEX,GACF,KAAK,gBAAgB,IAAI,EAAgB,GAAQ,EAAM,UAAU;OAC3D;GACN,KAAK,gBAAgB,EAAO,UAAU,EAAU,cAAc;GAC9D,IAAI,IAAa,EAAO,UAAU,CAAiB;GAEnD,AADA,EAAa,KAAK,cAAc,MAAM,GAAG,EAAW,gBAAgB,EAAW,gBAAgB,GAC/F,QAAQ,MAAM,KAAK,cAA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W,CAAC,IAAI,KACjC,KAAO,IAAI,SAAU,gBAAkB,MAAM,MAAM,aAAc,UAAW;CAC9E;CAMA,OAJA,KAAK,MAAM,IACX,KAAO,IAAI,SAAU,gBAAkB,MAAM,MAAM,aAAc,UAAW,KAC5E,KAAK,MAAM,IACX,OAAU,GACH;AACR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { SharedListMemory } from './shared-list';
|
|
1
|
+
import AllocatedMemory from './allocated-memory';
|
|
2
|
+
import type MemoryHeap from './memory-heap';
|
|
3
|
+
import type { SharedListMemory } from './shared-list';
|
|
4
4
|
export default abstract class SharedPointerList<T extends PointerItem> implements Iterable<T> {
|
|
5
5
|
private memory;
|
|
6
6
|
private list;
|
|
@@ -8,6 +8,7 @@ export default abstract class SharedPointerList<T extends PointerItem> implement
|
|
|
8
8
|
get length(): number;
|
|
9
9
|
insert(item: T): void;
|
|
10
10
|
delete(item: T): boolean;
|
|
11
|
+
compact(): void;
|
|
11
12
|
[Symbol.iterator](): Generator<T, void, unknown>;
|
|
12
13
|
forEach(callback: (item: T) => void): void;
|
|
13
14
|
find(callback: (item: T) => boolean): T | undefined;
|
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createPointer as e, loadPointer as t } from "./utils/pointer.js";
|
|
2
|
+
import n from "./allocated-memory.js";
|
|
2
3
|
import r from "./shared-list.js";
|
|
3
|
-
|
|
4
|
-
class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
u as default
|
|
4
|
+
//#region src/shared-pointer-list.ts
|
|
5
|
+
var i = class {
|
|
6
|
+
memory;
|
|
7
|
+
list;
|
|
8
|
+
constructor(e, t) {
|
|
9
|
+
this.memory = e, this.list = t ? new r(e, t) : new r(e);
|
|
10
|
+
}
|
|
11
|
+
get length() {
|
|
12
|
+
return this.list.length;
|
|
13
|
+
}
|
|
14
|
+
insert(t) {
|
|
15
|
+
this.list.insert(e(t.memory.bufferPosition, t.memory.bufferByteOffset));
|
|
16
|
+
}
|
|
17
|
+
delete(t) {
|
|
18
|
+
let n = this.list.deleteValue(e(t.memory.bufferPosition, t.memory.bufferByteOffset));
|
|
19
|
+
return this.list.compact(), n;
|
|
20
|
+
}
|
|
21
|
+
compact() {
|
|
22
|
+
this.list.compact();
|
|
23
|
+
}
|
|
24
|
+
*[Symbol.iterator]() {
|
|
25
|
+
let e = this.list[Symbol.iterator]();
|
|
26
|
+
for (let { data: r } of e) {
|
|
27
|
+
let { bufferPosition: e, bufferByteOffset: i } = t(r, 0), a = new n(this.memory, {
|
|
28
|
+
bufferPosition: e,
|
|
29
|
+
bufferByteOffset: i
|
|
30
|
+
});
|
|
31
|
+
yield this.createItem(a);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
forEach(e) {
|
|
35
|
+
for (let t of this) e(t);
|
|
36
|
+
}
|
|
37
|
+
find(e) {
|
|
38
|
+
for (let t of this) if (e(t)) return t;
|
|
39
|
+
}
|
|
40
|
+
getSharedMemory() {
|
|
41
|
+
return this.list.getSharedMemory();
|
|
42
|
+
}
|
|
43
|
+
free() {
|
|
44
|
+
for (let e of this) "free" in e && typeof e.free == "function" ? e.free() : e.memory.free();
|
|
45
|
+
this.list.free();
|
|
46
|
+
}
|
|
49
47
|
};
|
|
50
|
-
//#
|
|
48
|
+
//#endregion
|
|
49
|
+
export { i as default };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=shared-pointer-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-pointer-list.js","sources":["../src/shared-pointer-list.ts"],"sourcesContent":["import AllocatedMemory from './allocated-memory';\nimport type MemoryHeap from './memory-heap';\nimport type { SharedListMemory } from './shared-list';\nimport SharedList from './shared-list';\nimport { createPointer, loadPointer } from './utils/pointer';\n\nexport default abstract class SharedPointerList<T extends PointerItem> implements Iterable<T> {\n\tprivate memory: MemoryHeap;\n\tprivate list: SharedList;\n\n\tconstructor(heap: MemoryHeap, memory?: SharedListMemory) {\n\t\tthis.memory = heap;\n\n\t\tif(memory) {\n\t\t\tthis.list = new SharedList(heap, memory);\n\t\t} else {\n\t\t\tthis.list = new SharedList(heap);\n\t\t}\n\t}\n\n\tget length() {\n\t\treturn this.list.length;\n\t}\n\n\tinsert(item: T) {\n\t\tthis.list.insert(createPointer(item.memory.bufferPosition, item.memory.bufferByteOffset));\n\t}\n\tdelete(item: T) {\n\t\
|
|
1
|
+
{"version":3,"file":"shared-pointer-list.js","names":[],"sources":["../src/shared-pointer-list.ts"],"sourcesContent":["import AllocatedMemory from './allocated-memory';\nimport type MemoryHeap from './memory-heap';\nimport type { SharedListMemory } from './shared-list';\nimport SharedList from './shared-list';\nimport { createPointer, loadPointer } from './utils/pointer';\n\nexport default abstract class SharedPointerList<T extends PointerItem> implements Iterable<T> {\n\tprivate memory: MemoryHeap;\n\tprivate list: SharedList;\n\n\tconstructor(heap: MemoryHeap, memory?: SharedListMemory) {\n\t\tthis.memory = heap;\n\n\t\tif(memory) {\n\t\t\tthis.list = new SharedList(heap, memory);\n\t\t} else {\n\t\t\tthis.list = new SharedList(heap);\n\t\t}\n\t}\n\n\tget length() {\n\t\treturn this.list.length;\n\t}\n\n\tinsert(item: T) {\n\t\tthis.list.insert(createPointer(item.memory.bufferPosition, item.memory.bufferByteOffset));\n\t}\n\tdelete(item: T) {\n\t\tlet deleted = this.list.deleteValue(createPointer(item.memory.bufferPosition, item.memory.bufferByteOffset));\n\t\t// This wrapper is single-threaded per instance, so reclaim the tombstoned node right away\n\t\tthis.list.compact();\n\t\treturn deleted;\n\t}\n\n\tcompact() {\n\t\tthis.list.compact();\n\t}\n\n\t*[Symbol.iterator]() {\n\t\tlet iterator = this.list[Symbol.iterator]();\n\n\t\tfor(let { data: pointerData } of iterator) {\n\t\t\tlet { bufferPosition, bufferByteOffset } = loadPointer(pointerData, 0);\n\t\t\tlet allocatedMemory = new AllocatedMemory(this.memory, {\n\t\t\t\tbufferPosition,\n\t\t\t\tbufferByteOffset,\n\t\t\t});\n\t\t\tyield this.createItem(allocatedMemory);\n\t\t}\n\t}\n\tforEach(callback: (item: T) => void) {\n\t\tfor(let value of this) {\n\t\t\tcallback(value);\n\t\t}\n\t}\n\n\tfind(callback: (item: T) => boolean): T | undefined {\n\t\tfor(let value of this) {\n\t\t\tif(callback(value)) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tgetSharedMemory() {\n\t\treturn this.list.getSharedMemory();\n\t}\n\n\tprotected abstract createItem(allocatedMemory: AllocatedMemory): T;\n\n\tfree() {\n\t\tfor(let item of this) {\n\t\t\t// NOTE: Anything that allocates it's own memory (ie: type for Item) needs to call free for that class so we can clear all memory recursively\n\t\t\tif('free' in item && typeof item.free === 'function') {\n\t\t\t\titem.free();\n\t\t\t} else {\n\t\t\t\titem.memory.free();\n\t\t\t}\n\t\t}\n\n\t\tthis.list.free();\n\t}\n}\n\ninterface PointerItem {\n\treadonly memory: AllocatedMemory\n}"],"mappings":";;;;AAMA,IAA8B,IAA9B,MAA8F;CAC7F;CACA;CAEA,YAAY,GAAkB,GAA2B;EAGxD,AAFA,KAAK,SAAS,GAEd,AAGC,KAAK,OAHH,IACU,IAAI,EAAW,GAAM,CAAM,IAE3B,IAAI,EAAW,CAAI;CAEjC;CAEA,IAAI,SAAS;EACZ,OAAO,KAAK,KAAK;CAClB;CAEA,OAAO,GAAS;EACf,KAAK,KAAK,OAAO,EAAc,EAAK,OAAO,gBAAgB,EAAK,OAAO,gBAAgB,CAAC;CACzF;CACA,OAAO,GAAS;EACf,IAAI,IAAU,KAAK,KAAK,YAAY,EAAc,EAAK,OAAO,gBAAgB,EAAK,OAAO,gBAAgB,CAAC;EAG3G,OADA,KAAK,KAAK,QAAQ,GACX;CACR;CAEA,UAAU;EACT,KAAK,KAAK,QAAQ;CACnB;CAEA,EAAE,OAAO,YAAY;EACpB,IAAI,IAAW,KAAK,KAAK,OAAO,SAAS,CAAC;EAE1C,KAAI,IAAI,EAAE,MAAM,OAAiB,GAAU;GAC1C,IAAI,EAAE,mBAAgB,wBAAqB,EAAY,GAAa,CAAC,GACjE,IAAkB,IAAI,EAAgB,KAAK,QAAQ;IACtD;IACA;GACD,CAAC;GACD,MAAM,KAAK,WAAW,CAAe;EACtC;CACD;CACA,QAAQ,GAA6B;EACpC,KAAI,IAAI,KAAS,MAChB,EAAS,CAAK;CAEhB;CAEA,KAAK,GAA+C;EACnD,KAAI,IAAI,KAAS,MAChB,IAAG,EAAS,CAAK,GAChB,OAAO;CAKV;CAEA,kBAAkB;EACjB,OAAO,KAAK,KAAK,gBAAgB;CAClC;CAIA,OAAO;EACN,KAAI,IAAI,KAAQ,MAEf,AAAG,UAAU,KAAQ,OAAO,EAAK,QAAS,aACzC,EAAK,KAAK,IAEV,EAAK,OAAO,KAAK;EAInB,KAAK,KAAK,KAAK;CAChB;AACD"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { SharedAllocatedMemory } from './allocated-memory';
|
|
2
|
-
import { TypedArrayConstructor } from './interfaces/typed-array-constructor';
|
|
3
|
-
import
|
|
1
|
+
import type { SharedAllocatedMemory } from './allocated-memory';
|
|
2
|
+
import type { TypedArrayConstructor } from './interfaces/typed-array-constructor';
|
|
3
|
+
import type MemoryHeap from './memory-heap';
|
|
4
4
|
export default class SharedPool<T extends Uint32Array | Int32Array | Float32Array | Float64Array = Uint32Array> implements Iterable<T> {
|
|
5
|
-
static readonly ALLOCATE_COUNT
|
|
5
|
+
static readonly ALLOCATE_COUNT = 6;
|
|
6
6
|
private memory;
|
|
7
7
|
private firstBlock;
|
|
8
8
|
private uint16Array;
|
|
9
|
-
private
|
|
10
|
-
private
|
|
9
|
+
private growLock;
|
|
10
|
+
private pointerStack;
|
|
11
|
+
private recycleStack;
|
|
12
|
+
readonly maxLength: number;
|
|
11
13
|
private cachedFullDataBlock;
|
|
14
|
+
private readonly cachedMaxChunkSize;
|
|
15
|
+
private readonly cachedDataLength;
|
|
16
|
+
private readonly cachedType;
|
|
17
|
+
private readonly cachedByteMultipler;
|
|
12
18
|
get length(): number;
|
|
13
19
|
get maxChunkSize(): number;
|
|
14
20
|
private set maxChunkSize(value);
|
|
@@ -17,8 +23,8 @@ export default class SharedPool<T extends Uint32Array | Int32Array | Float32Arra
|
|
|
17
23
|
get dataLength(): number;
|
|
18
24
|
private set dataLength(value);
|
|
19
25
|
get bufferLength(): number;
|
|
20
|
-
get recycleBufferLength(): number;
|
|
21
26
|
get byteMultipler(): number;
|
|
27
|
+
get usedMemory(): number;
|
|
22
28
|
constructor(memory: MemoryHeap, config?: SharedPoolConfig<T> | SharedPoolMemory);
|
|
23
29
|
at(index: number): T;
|
|
24
30
|
get(index: number, dataIndex?: number): number;
|
|
@@ -33,9 +39,10 @@ export default class SharedPool<T extends Uint32Array | Int32Array | Float32Arra
|
|
|
33
39
|
}
|
|
34
40
|
interface SharedPoolConfig<T extends Uint32Array | Int32Array | Float32Array | Float64Array> {
|
|
35
41
|
maxChunkSize?: number;
|
|
42
|
+
maxLength?: number;
|
|
43
|
+
maxRecycledLength?: number;
|
|
36
44
|
type?: TypedArrayConstructor<T>;
|
|
37
45
|
dataLength?: number;
|
|
38
|
-
recycleBufferLength?: number;
|
|
39
46
|
}
|
|
40
47
|
interface SharedPoolMemory {
|
|
41
48
|
firstBlock: SharedAllocatedMemory;
|